Automation Object model

Automation Object Model in HPE UFT!

An object model is a logical interface, software or system that is modeled through the use of object-oriented techniques. It enables the creation of an architectural software or system model prior to development or programming. Automation object Model (AOM) can be understood as a structural representation of objects that comprise the implementation of the software or application.

HP UFT provides a COM interface that allows automation of UFT itself. This AOM enables user to write code to perform the core UFT tasks such as:

  1. Launching UFT
  2. Configuring UFT
  3. Running a UFT Test script
  4. Loading the add-ins
  5. Changing the iterations for a test script
  6. Passing arguments to a test script
  7. Launching UFT on a remote machine

How to launch UFT, open and execute a test script using AOM?

‘Create an instance of the UFT application

Set uftApp = CreateObject(“QuickTest.Application”)


uftApp.Visible = True

‘Open a test script

uftApp.Open “C:\Test UFT”\Sample Test”,True

‘Run the test


‘Closing UFT


Set uftApp = Nothing

Loading add-ins at run-time

Select Add-ins

‘Create an array containing the list of add-ins associated with this test

arrTestAddins = uftApp.GetAssociatedAddinsForTest(“C:TestsTest1”)
‘Check if all required add-ins are all already loaded
blnNeedChangeAddins = False ‘Assume no change is necessary

‘Iterate over the test’s associated add-ins list

For Each testAddin In arrTestAddins

‘If an associated add-in is not loaded
If uftApp.Addins(testAddin).Status <> “Active” Then

blnNeedChangeAddins = True ‘change in the loaded add-ins is necessary
Exit For

End If

‘If change in the loaded add-ins is necessary
If blnNeedChangeAddins Then

Dim blnActivateOK

‘Load the add-ins associated with the test and check whether they load successfully.
blnActivateOK = qtApp.SetActiveAddins(arrTestAddins, errorDescription)

‘If a problem occurs while loading the add-ins

If Not blnActivateOK Then
WScript.Quit ‘End the automation program.
End If

End If

Changing the iterations for a test script

‘To run for iterations 5 to 9

uftApp.Test.Settings.Run.IterationMode = “rngIterations”

uftApp.Test.Settings.Run.StartIteration = 5

uftApp.Test.Settings.Run.EndIteration = 9

‘Stop in case of any errors

uftApp.Test.Settings.Run.OnError = “Stop”


Similarly we can write codes for automating other UFT functionalities with the help of Automation object model. Keep an eye on this website for other related articles.




Leave a Reply

Your email address will not be published. Required fields are marked *