How to update an repository object in uft? - vbscript

I use UFT 11.53, Windows 8.1 Pro et vbscripts.
I've a question : Is it possible to add objects to an object repository automatically using VBScript?
My problem : I've an application in which I've to automate tests and qualifications. I would like to add an new object (using vbscript) to my repository object.
Below is my code which I tried:
Dim RepositoryFrom
Dim ParentObject
ObjectRepositoryPath="D:\repository.tsr"
'Creating Object Repository utility Object
Set RepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil")
'Load Object Repository
RepositoryFrom.Load ObjectRepositoryPath
Set oWebElement = WebElement(""&str) 'str = "PR1500073LRBA", it's an element of my table
Set ParentObject = Browser("fia").Page("fia_3")
RepositoryFrom.AddObject oWebElement, ParentObject, "reference"
RepositoryFrom.Save
Set RepositoryFrom = nothing
Set oWebElement = nothing
Set oParent = nothing
With this code, I've an message error :
'AddObject' - General error.
Line (63): "RepositoryFrom.AddObject oWebElement, ParentObject, "reference"".
Do you know why I've this message ?
Thanks :)

Related

Not able to update the tester name in a Test Set from vbscript

I am been trying to search online for a solution but due to lack of knowledge in HP ALM I am not able to search proper hit tags
Set RunFactory = tsTest.RunFactory
Set obj_theRun = RunFactory.AddItem(CStr(testrunname))
obj_theRun.Status = sExecutionStatus '"Passed" '-- Status to be updated
obj_theRun.Tester = strTesterName
Getting error in this line object does not support obj_theRun.Tester
I just want to update the Tester column(Not Responsible tester) in Test set via vbscript. Please refer to the attached image at the very last column (TesterAny help is appreciated. Thank you in advance.
The documentation for ALM says the Tester Name can be specified by passing an array as the argument to AddItem.
https://admhelp.microfocus.com/alm/api_refs/ota/Content/ota/topic8805.html?Highlight=tester
An array consisting of the following elements:
Name - The name of the run (string. required).
Tester - The name of the user responsible (string. optional)
Location - The host name (string. optional). The default is the host name of the current machine
So change your code to this:
Set runFactory = tsTest.RunFactory
Dim newRunArgs(3)
newRunArgs(0) = testrunname ' `testrunname` is already a string so you don't need CStr.
newRunArgs(1) = "tester name goes here"
Set newRunArgs(2) = Nothing
Set newRun = RunFactory.AddItem( newRunArgs )
newRun.Status = sExecutionStatus '"Passed" '-- Status to be updated

Update function not working in vb.net

Currently I'm develop a system using VB.NET. I have the following query for UPDATE. This query is work when I run in SQL Developer
UPDATE CCS2_TBL_INSPECTION_STANDARD SET CCSEQREVITEM = :CCSEQREVITEM,
CCSREVEFFECTIVEDATE = TO_DATE(:CCSREVEFFECTIVEDATE,'DD/MM/YYYY') WHERE
CCSEQID = :CCSEQID
But when I try applied this query in VB.net, its not work. Actually the flow for this update function is work but when I update the data, it is not working. For example, I want update name from 'Ali' to 'Abu', when I click the update button, there popup windows says that "Update success" but the name is not change to 'Abu', it still 'Ali'. There no error when I execute. Anyone know? Below VB.net code:
Protected Sub editInspectionRev(eqid As String)
Dim xSQL As New System.Text.StringBuilder
xSQL.AppendLine("UPDATE CCS2_TBL_INSPECTION_STANDARD")
xSQL.AppendLine("SET")
xSQL.AppendLine("CCSEQREVITEM = :CCSEQREVITEM, CCSREVEFFECTIVEDATE = TO_DATE(:CCSREVEFFECTIVEDATE,'DD/MM/YYYY')")
xSQL.AppendLine("WHERE CCSEQID = :CCSEQID")
Using cn As New OracleConnection(ConString)
cn.Open()
Dim cmd As New OracleCommand(xSQL.ToString, cn)
cmd.Connection = cn
cmd.Parameters.Add(":CCSEQREVITEM", txtRevContent.Text)
cmd.Parameters.Add(":CCSREVEFFECTIVEDATE", txtRevEffDate.Text)
cmd.Parameters.Add(":CCSEQID", eqid)
cmd.ExecuteNonQuery()
cn.Close()
End Using
success3.Visible = True
DisplayRevisionDetails()
End Sub
The problem is that you have executed the transaction but failed to COMMIT it. There is an example of the correct method here, which I will reproduce in part below for posterity
Using connection As New OracleConnection(connectionString)
connection.Open()
Dim command As OracleCommand = connection.CreateCommand()
Dim transaction As OracleTransaction
' Start a local transaction
transaction = connection.BeginTransaction(IsolationLevel.ReadCommitted)
' Assign transaction object for a pending local transaction
command.Transaction = transaction
...
command.ExecuteNonQuery()
transaction.Commit()
Observe that we have begun the transaction, and then committed it after executing.

VBScript: Create object throws error

Below are the cases i tried to create object of instance "COMAdmin.COMAdminCatalogCollection".
But I`m getting error saying:
"Microsoft VBScript runtime error: ActiveX component can't create object: 'COMAdminCatalogCollection'"
Code:
dim aa,bb,cc
set aa = new ActiveXObject("COMAdmin.COMAdminCatalogCollection")
'Set bb = Createobject("COMAdmin.COMAdminCatalogCollection")
'set cc = Createobject("COMAdminCatalogCollection")
I dont have any idea about the instance "COMAdmin.COMAdminCatalogCollection", I tried to find dlls to register to fix the issue I got nothing on internet.
Thanks in advance.
Try to get Collection from COMAdminCatalog
Set objCatalog = CreateObject("COMAdmin.COMAdminCatalog")
Set oTSCol = objCatalog.GetCollection("TransientSubscriptions")
Set objCatalog = nothing

VBScript: Assigning an array(2) via createobject

I'm having a problem converting this VB6 code to VBScript. I'm calling out to a COM object to create an array as EmailAddressType. Here is the working VB6 Code:
'Assign TO: addresses
Dim toAdresses(2) As New EmailAddressType
toAdresses(0).EmailAddress = "someone#whocares.com"
toAdresses(0).RoutingType = "SMTP"
toAdresses(1).EmailAddress = "someoneelse#whocares.com"
toAdresses(1).RoutingType = "SMTP"
email.ToRecipients = toAdresses
I can't seem to figure out how to convert this into VBScript. I've tried the following but just get a Type Mismatch error once I get to the email.ToRecipients = toAdresses
'Assign TO: addresses
dim toAdresses(2)
set toAdresses(0) = createobject("EWS.EWSWebSvc.EmailAddressType")
set toAdresses(1) = createobject("EWS.EWSWebSvc.EmailAddressType")
toAdresses(0).EmailAddress = "someone#whocares.com"
toAdresses(0).RoutingType = "SMTP"
toAdresses(1).EmailAddress = "someoneelse#whocares.com"
toAdresses(1).RoutingType = "SMTP"
email.ToRecipients = toAdresses
Btw this is a COM wrapper of the Exchange Web Services if that helps any.
I think the problem is that the .ToRecipients property wants an array of EmailAddressType while all you can easily get in VBScript is a Variant or array of Variants.
Looks like this API was just not built to be scriptable.
Oddly enough there is an implication it can be used from JScript though: MessageType.ToRecipients Property
I suspect they are rewriting history by gradually editing out any mention of VBScript on MSDN these days though.
Just a guess, try this
toAdresses.EmailAddress = "someone#whocares.com;someoneelse#whocares.com"
toAdresses.RoutingType = "SMTP"
email.ToRecipients = toAdresses
if it doesn't work with the ; try the ,

Setting a VCProject property to default

I'm trying some VS2005 IDE macros to modify a large amount of projects (~80) within a solution. Some of the properties I wish to set do expose a programmatic interface to 'default', but many others do not. Is there a generic way to set such properties to their default? (eventually meaning erasing them from the .vcproj file)
Simplified example, setting some random properties:
Sub SetSomeProps()
Dim prj As VCProject
Dim cfg As VCConfiguration
Dim toolCompiler As VCCLCompilerTool
Dim toolLinker As VCLinkerTool
Dim EnvPrj As EnvDTE.Project
For Each EnvPrj In DTE.Solution.Projects
prj = EnvPrj.Object
cfg = prj.Configurations.Item(1)
toolLinker = cfg.Tools("VCLinkerTool")
If toolLinker IsNot Nothing Then
' Some tool props that expose a *default* interface'
toolLinker.EnableCOMDATFolding = optFoldingType.optFoldingDefault
toolLinker.OptimizeReferences = optRefType.optReferencesDefault
toolLinker.OptimizeForWindows98 = optWin98Type.optWin98Default
End If
toolCompiler = cfg.Tools("VCCLCompilerTool")
If toolCompiler IsNot Nothing Then
' How to set it to default? (*erase* the property from the .vcproj)'
toolCompiler.CallingConvention = callingConventionOption.callConventionCDecl
toolCompiler.WholeProgramOptimization = False
toolCompiler.Detect64BitPortabilityProblems = False
End If
Next
End Sub
Any advice would be appreciated.
For VS 2005, I believe you can use the ClearToolProperty method on VCConfiguration. The following code would accomplish this for CallingConvention (this is C#, but I'm sure something similar works for VB):
cfg.ClearToolProperty( toolCompiler, "CallingConvention" );
This would have the same effect as going into the GUI and choosing "<inherit from parent or project defaults>" for this option.
Unfortunately this seems to be deprecated in VS 2010, and I'm not sure what the new supported method is.

Resources