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:
- Launching UFT
- Configuring UFT
- Running a UFT Test script
- Loading the add-ins
- Changing the iterations for a test script
- Passing arguments to a test script
- 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
Set uftApp = Nothing
Loading add-ins at run-time
‘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
‘If change in the loaded add-ins is necessary
If blnNeedChangeAddins Then
‘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.
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.
Looking for a Job Change in QA/Testing technology? Get Regular Job notifications @ WhatsApp!