08 November 2017

AOM - Automation Object Model

'Creating QuicTest Object
Set qtapp = createobject("QuickTest.Application")

'Launching the Application
If qtapp.Launched<> Ture Then
    qtapp.Launch
End If

qtapp.Visible = True

'Connecting to ALM
If Not qtapp.TDConnection.IsConnected Then
    qtapp.TDConnection.Connect "QC_URL""Domain","Project","User","pwd"
End If

'Open a Test script
qtapp.Open "C:\UFT\Test1"True

'Get all Associated Addins and Print them all
adins = qtapp.Test.GetAssociatedAddins

For i = 1 To ubound(adins)
    msgbox adins(i)
Next

'Get the count of Actions associated with the test and Print them all
actions = qtapp.Test.Actions.Count

For i = 1 To actions
    msgbox qtapp.Test.Actions(i).Name
Next

'Get the count of Associated Function Libraries
lcount = qtapp.Test.Settings.Resources.Libraries.Count

'Find and add Library file to the test if not found
set Lib = qtapp.Test.Settings.Resources.Libraries

If Lib.Find("C:\UFT\lib.vbs") = -1 Then
    Lib.Add "C:\UFT\lib.vbs"1     'Position like 1,2
End If

'Find and add Object Repository fie to the test if not found
Set rep = qtapp.Test.Actions("Action1").ObjectRepositories

If rep.Find("C:\UFT\rep.tsr") = -1 Then
    rep.Add "C:\UFT\rep.tsr"1     'Position like 1,2
End If

'Adding recovery scenario to the Test
qtApp.Test.Settings.Recovery.Add "C:\UFT\Recover.qrs""Recover"1    'Position like 1,2

'Enabling the Recovery scenario
qtApp.Test.Settings.Recovery.Item(1).Enabled = True

'Saving the Test
qtapp.Test.Save



'*********************************
'Some Run Settings
qtApp.Test.Settings.Run.IterationMode = "rai"
qtApp.Test.Settings.Run.StartIteration = 1
qtApp.Test.Settings.Run.EndIteration = 1
qtApp.Test.Settings.Run.DisableSmartIdentification = False

'Some Log Tracking Settings
With App.Test.Settings.LogTracking
    .IncludeInResults = False
    .Port = 18081
    .IP = "127.0.0.1"
    .MinTriggerLevel = "ERROR"
    .EnableAutoConfig = False
    .RecoverConfigAfterRun = False
    .ConfigFile = ""
    .MinConfigLevel = "WARN"
End With

'***********************************


'Executing the Test
set qtest = qtapp.Test

'Performing next step if any error found
qtest.Settings.Run.OnError = "NextStep"

'Create the Run Results Options object and Save the Run Result
Set qtestResults = CreateObject("QuickTest.RunResultsOptions")

qtestResults.ResultsLocation = "C:\UFT\Res1" ' Set the Location

'Run the test 
qtTest.Run qtResultsOpt

MsgBox qtTest.LastRunResults.Status ' Check the results of the test run 

qtApp.Quit         'Close QuickTest
Set qtResultsOpt = Nothing        'Release the Run Results Options object 
Set qtApp = Nothing        'Releasing the memory


....

No comments:

Post a Comment

AOM - Automation Object Model

'Creating QuicTest Object Set  qtapp =  createobject ( "QuickTest.Application" ) 'Launching the Application If  qtapp...