How To Work With Automation Object Model In UFT?

What is Automation Object Model In UFT?

AOM stands for the Automation Object Model. This is a way to use UFT/QTP  and its resources. By this approach, we can control the QTP from a separate program like-a VBS, macro. This is accomplished using the COM interface. that gives them the freedom to access the all most 90% of the components of the software.

Using UFT/QTP we can automate the application under test, and using the AOM- Automatic Object Model, we can automate the UFT/QTP itself. By Using the objects, methods, and properties exposed by the UFT/QTP automation object model, we can write scripts that configure UFT/QTP options and run components instead of performing these operations manually using the UFT/QTP interface.

Based on COM, AOM can communicate with the components. (access different methods, properties, object). It provides a set of controls, methods to help a developer/automation tester to execute the script without touching UFT. It is externally useful while triggering batch run from Jenkins or making one-click automation.

What is the proper use case for Automation Object Model?

Automation scripts are especially useful for performing the same tasks multiple times or on multiple components, or quickly configuring UFT/QTP according to our needs for a particular environment or application.

we can use the UFT/QTP Professional automation object model to write scripts that automate our UFT/QTP operations. The UFT/QTP automation object model provides objects, methods, and properties that enable us to control UFT/QTP from another application.

  • This is useful when we want to change the QTP /UFT options during run time
  • Want to control UFT/QTP from our other application
  • Want to do some repetitive task in a regular interval
  • Migrating to continuous integration
  • I want to schedule scripts in a machine.

AOM is the better solution for the above uses. It uses COM (Component Object Model)- In the below section, we will see how to create an object of UFT application and work with different components of it.

What is AOM- Automatic Object Model ?

Essentially all configuration and run functionality provided via the UFT/QTP interface is in some way represented in the UFT/QTP automation object model via objects, methods, and properties.Although a one – on – one comparison cannot always be made, most dialog boxes in UFT/QTP have a corresponding automation object, most options in dialog boxes can be set and/ or retrieved using the corresponding object property, and most menu commands and other operations have corresponding automation methods.

We can use the objects, methods, and properties exposed by the UFT/QTP automation object model, along with standard programming elements such as loops and conditional statements to design our script.

Automation scripts are especially useful for performing the same tasks multiple times or on multiple tests or components, or quickly configuring UFT/QTP according to our needs for a particular environment or application.

For example, we can create and run an automation script from Microsoft Visual Basic that loads the required add-ins for a test or component, starts UFT/QTP invisible mode, open the test or component, configures settings that correspond to those in the Options, Test or Business component Settings, and Record and Run Settings dialog boxes, runs the test or component and saves the test or component.

We can then add a simple loop to our script so that our single script can perform the operations described above for multiple tests or components.

we can also create an initialization script that opens UFT/QTP with specific configuration settings. We can then request all our test engineers to open UFT/QTP using the automation script to ensure that all of our testers are always working with the same configuration.

Stategies when to use Automation of UFT/QTP

Creating a useful UFT/QTP automation script requires planning, design time and testing we must always weigh the initial investment with the time and human – resources saving us from automating potentially long or tedious tasks.

Any UFT/QTP operation that we must perform many times in a row or must perform on a regular basis is a good candidate for a UFT/QTP automation script.

The following are just a few examples of useful UFT/QTP automation scripts:

  • Initialization scripts – we can write a script that automatically starts UFT/QTP and configures the options and the settings required for recording on a specific environment.
  • Maintaining our tests or components – we can write a script that iterates over our working collection of tests and components to accomplish a certain goal.
  • Updating values – we can write a script that opens each test or component with the proper add-ins, runs it in update run mode against an updated application and saves it when we want to update the values in all of our tests and components to match the updated values in our application.
  • Applying new options to existing tests or components – When we upgrade to a new version of UFT/QTP, we may find that the new version offers certain options that we want to apply to our existing tests and components. we can write a script that opens each existing test and component, sets values for the new options, then saves and closes it.
  • Calling UFT/QTP from other applications -we can design our own applications with options or controls that run UFT/QTP automation scripts. For an example, we can create a Web form or simple Windows interface from which a product manager can schedule UFT/QTP runs, even if the manager is not familiar with UFT/QTP.
See also  9 Frequently Faced Issues for QTP or UFT with Detailed Solutions

Basic Elements of Automatic Object Model

Like most automation object models, the root object of the UFT/QTP automation object model is the Application object. The Application object represents the application level of UFT/QTP.

we can use this object to return other elements of UFT/QTP Test such as the Test object (Which represents a test or component document), Options object represents(which represents the Options dialog box), or Addins collection (which represents a set of add – ins from the Add in manager dialog box), and to perform operations like loading add – ins starting UFT/QTP, opening and saving tests or components, and closing UFT/QTP.

Each object returned by the Application object can return other objects, perform operations related to the object and retrieve and/ or set properties des associated with that object.

Every automation script begins with the creation of the UFT/QTP Application object. Creating this object does not start UFT/QTP. It simply provides an object from which we can access all other objects,methods and properties of the UFT/QTP automation object model.


There are three popular ways to create an object of the quick test-

Visual Basic Way:

Dim qtApp as QuickTest.Application
set qtApp=New QuickTest.Application

VBScript way:

Dim qtApp
set qtApp=CreateObject("QuickTest.Application")

Java Script way

var qtApp=new ActiveXObject("QuickTest.Application")

You can choose anyone. But in this blog I am going to take Vb scripting: The structure for the rest of our script depends on the goals of the script. we may perform a few operations before we start UFT/QTP such as retrieving the associated to add – ins for a test or component, loading add – ins, and instructing UFT/QTP to open in visible mode.

After we perform these preparatory steps, if UFT/QTP is not already open on the computer, we can open UFT/QTP using the Application. Launch method. Most operations in our automation script are performed after the Launch method.

When we finish performing the necessary operations, or we want to perform operation require closing and restarting UFT/QTP, such as changing the set of loaded add – in, we need to use Application.Quit method.


Basic Settings

Dim qtApp
set qtApp=CreateObject("QuickTest.Application")
qtApp.Launch  ' launch QTP/UFT
qtApp.Activateview "Expertview" 'Open Expert View can be "keyWordView"
qtApp.showPaneScreen "ActiveScreen",True 'show the Active Screen can also be set 
'as "Debugviewer",True or "DataTable" False
qtApp.WindowState="Maximized" 'Maximize the UFT,can aslo be set as "Minimized"

Run Options"onError""Fast" can be set to Normal or slow based on the network speed ' can be true if you want the qtp result to display 
'after a run
qtApp.Test.Settings.Run.DisableSmartIdentification=false 'can be true

Run Settings

This can be achieved in two ways …

  1. Either you follow the hierarchy
  2. Or create an object of the test module


set qtTest=qtApp.Test"AllIterations" ' can be rngIterations or rngAll
'to run from iteration x to iteration y"NextStep" 'can be stopped by passing "Stop"
' or we can show error dialog by passing "Dialog"

Result Settings

Dim qtResultOpt
set qtResultOpt=CreateObject("quickTest.Run ResultsOptions")
qtTest.Run qtResultOpt

if you move all result to a file:

const forReading=1
const forWritting=2
dim fso,f,result
set fso=CreateObject("scripting.FileSystemObject")
set f=fso.openTextfile("c:testresult.txt",forWritting,True)
'you can create the text file by using fso
set qtResultOpt=CreateObject("quickTest.Run ResultsOptions")
qtTest.Run qtResultOpt
f.write("test1:Name of the test")
'close f,set objects to null if you have no further use

Library Settings

dim qtlibs
'to remove all
Add a library:
If qtLibs.find("path of the lib"abc.vbs")=-1 then
qtlibs.Add "path of the lib"abc.vbs",1
End If
qtApp.Test.Save ' in this case you have to open the test in edit mode,readonly flse


Repository Settings

set qtRepositories=qtApp.Test.Action("Action Name").ObjectRepositories ' for which the 
'repository needs to be added
If qtRepositories.find("path of the lib"abc.tsr")=-1 then
qtRepositories.Add "path of the lib"abc.tsr",1
End If

Environment Variable Settings


Action Settings

qtApp.Test.Actions.Count 'return the actions present in the test
qtApp.Test.Actions("Name of the action like 'Action1'").Description
'returns the description
qtApp.Test.Actions("Name of the action like 'Action1'").Name
'returns the name
'run a particular action by index
qtApp.Test.Actions(index as 1/2).Run
RunAction "Action2",oneIteration 'can be multiple iterations by providing the iteration number

Recovery Settings

'removing all recovery
set qtTestRecovery=qtApp.Test.Settings.Recovery
If qtTestRecovery.count>0 then
End If
'add recovery
qtTestRecovery.Add "path of the recovery file","Name of the recovery",1,"description"

‘enabling the recovery:

For intIndex=1 to qtTestRecovery.count
'specify when to activate

Datatable Settings

qtApp.Test.Settings.Resources.DataTablePath="Path of your data table"

Log tracking Settings

with qtApp.Test.Settings.LogTracking
End With

There are two launchers available out of the box.

  1. Web Application
  2. Window Application


Web launcher Settings

qtApp.Test.Settings.Launcher("Web").Activate=true 'can be false
qtApp.Test.Settings.Browser="IE", Can be chrome,firefox if supports

Windows Application launcher Settings

qtApp.Test.Settings.Launcher("Window Application").Activate=true 'can be false
qtApp.Test.Settings.Applications.RemoveAll 'removes all pre loaded Applications
qtApp.Test.Settings.RecordOnQTDescendant="False" 'record settings

Addins Settings

arrAddins=qtApp.GetAssociatedAddinsForTest("Test path and Test Name")
'check if loading is successful
For Each testAddin in arrAddins
If (qtApp.Addins(testAddin)).status <> "Active" then
Exit for
End if
'if change in the loaded addins is necessary
If blnAddinRequired Then
Dim blnActivateOk
blnActivateOk=qtApp.SetActiveAddins(arrAddins,error description)
If Not blnActivateOk Then
End if
End if 

Set Parameters

To work with these, we need to create these parameters in QTP first.

Set pDefcoll=qtApp.Test.ParameterDefination
Set qtpParam=pDefcoll.GetParameters()
on Error Resume Next

How to save Test

If qtApp.Test.IsNew Then
qtApp.Test.SaveAs "path of the script and Script Name"
End If

How to Connect To ALM/QC

qtApp.TDConnections.Connect "QCURL","Domain","Project Name","UserName","Password",false

How to Run a Test from ALM/QC

qtApp.TDConnections.Connect "QCURL","Domain","Project Name","UserName","Password",false
If qtApp.TDConnection.IsConnected Then
qtApp.Open [QualityCentre]Subjectpathscript Name,False

How to Log a bug in ALM/QC
Here is a complete guide of the code: Here is a small different way to do:

Dim qcApp
 Dim BugFact,NewBug
Set qcApp = CreateObject("TDApiOle80.TDConnection")
'Intilizing the QC connection
qcApp.InitConnectionEx ""
'Verifying User is connected
If qcApp.Connected Then
Print "User Connected to ALM Server"
Print "User is not Connected to ALM Server"
Exit Function
End If
'Filling the UserName and Password for ALM
qcApp.Login sUName,sPwd
'Verifying User is Logged into ALM
If qcApp.LoggedIn Then
Print "User is Logged into ALM Server"
Print "User is not Logged into ALM Server"
Exit Function
End If
'Connects user to specified Domain and Project
qcApp.Connect sDomain,sProject
Set BugFactory=qcApp.BugFactory
Set Bug=BugFactory.AddItem(Nothing)
Bug.Summary="Test Bug"
Bug.AssignedTo="Dev Team"

Easy Way to Build this AOM file: Setup everything in UFT/QTP:

Option 1: Go to test settings->General Tab–>Object Identification Tab–>Click on Generate button–>Provide the path–>Provide the name–>Click on save

Option 2: Go to Test–>Settings–>Properties Tab–>Click on Generate button–>Provide the path–>Provide the name–>Click on save

Option-3:Go to tools->Option–>General Tab–>Click on Generate button–>Provide the path–>Provide the name–>Click on save after few settings you will be able to understand the settings.

How to Close Any Application From VBA,QTP,VBScript?

Few other things that can be done via AOM:
This is the code where you can close any application.Even from QTP/UFT, You can give this command to stop any application. Logic The steps are…

  • Go to Task Manager.
  • Find out which application you want to close.
  • Right-click on it.
  • Go to the process and Select it.
  • It will navigate you to the Process page.
  • Just remember the process name of the corresponding application.
See also  VBScript Data Types: Know Everything in Quick 5 Minutes


Private Function CloseAppliction()
Set objWMIService = GetObject("winmgmts:\.rootCIMV2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = qlock.exe'")
For Each objProcess in colProcess
Set objWMIService = Nothing
Set colProcess = Nothing
End Function

Public Function fn_close_all_excel_files()
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootcimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'EXCEL.EXE'")
For Each objProcess in colProcessList
End Function

How to Connect QTP or UFT with QC?

Set qtApp = CreateObject("QuickTest.Application")
If qtApp.TDConnection.IsConnected Then
msgbox "QC"
msgbox "Local"
End If

Another way:

if QCUtil.IsConnected then
Reporter.ReportEvent 0, "Connected", "Connected to server: " + QCUtil.QCConnection.ServerName + chr (13) +"Project: " +
QCUtil.QCConnection.ProjectName + chr (13) + "Domain: " + QCUtil.QCConnection.DomainName
Reporter.ReportEvent 1, "Not connected", "Not connected to Quality Center"
end if

Refer the below code under Library Settings

dim qtlibs
'to remove all
Add a library:
If qtLibs.find("path of the lib"abc.vbs")=-1 then
qtlibs.Add "path of the lib"abc.vbs",1
End If
qtApp.Test.Save ' in this case you have to open the test in edit mode,readonly false

But there two ways to do that:
1. Execute File <path of the VBS/qfl file>
You have to write these lines for all library files one by one.
2. LoadFunctionLibrary <path of qfl/vbs> We can give many library files path with names separated by comma(,). I could have opted for one of these two methods, but one issue compelled me to think otherwise. The issue was, there could be multiple libraries as and when the project grows up.

So every time, if a person going to add a new function library, Somebody needs to update the above lines in code just to load the files. That triggered the cost of maintenance during function library addition.

Below is a way I have coded to handle addition of all libraries with our script dynamically using AOM way : The precondition is to have a folder called Libraries where we need to place all libraries.

Dim qtApp
Set qtApp=CreateObject("QuickTest.Application")
Set objFso=CreateObject("Scripting.FileSystemObject")
objLibPath=path of our Library folder ' Like C:TestLibrary
Set objFolder=objFso.GetFolder(objLibPath)
Set colFiles=objFolder.Files
qtApp.Launch ' launch QTP/UFT
Set objLib=qtApp.Test.Settings.Resources.Libraries
For Each objFile in colFiles
If Not instr(fileName,".lck") Then ' sometimes I have seen .lck files are
'created and not destroyed even if the QTP is closed
if objLib.Find(objLibPath&fileName)=-1 Then
objLib.Add objLibPath&fileName
End If
objFile.Delete 'Delete the .lck file
End If

How To Get Desktop Path Dynamically In QTP or UFT?

In my initial days with QTP, frequently I needed to download some file to upload or download from or to the desktop.
To be on safe side I always used an Environment variable which carried the value of the Desktop path.
Like –Environment(“Desktop”).value= “path of the machine”
So in every release, I use to tag this script as needs update during rerun in different machines.

Later I found a nice solution to find out the desktop path dynamically.

Set WSHShell = CreateObject("WScript.Shell")
strShortcutLoc = WSHShell.SpecialFolders("Desktop")

This is a Tested code that can be used to any machine. My problem resolved.

How to make a script location independent in UFT or QTP?

When my manager takes the script, he wants to run them from his D drive. But I have written the scripts in such a way that it gets executed and stores the results in an Excel at C drive. To avoid this, I want to get the current folder path. How to do that?

The way to make script location-neutral

what is required is to take the test path dynamically i.e how to make a script drive/area independent?

let’s do it…

now go to

Script location independent UFT

This is the option by which QTP determines from here the script is running. These are all environmental variables. Now what you need to do is to take the path by using the environment variable.

now if you are using this command…i.e. environment of test path…this will dynamically give you the path of the test running folder.

now configure your testing here I mean the path and the folder structure. your problem is solved.

How to Stop Screensaver or Screenlock in UFT or QTP via code?

The scrips while running on unattended mode, needs this feature to disable screensaver or screen lock during script execution.

This section is useful while we perform automation testing for more than 200 rows of data. As per our office or company policy, if a system is untouched for 15 minutes, the screen lock feature gets activated and we need a password to open the screen again. Automation faces regular challenges due to this activity. It is not always okay for UFT to get the screen locked. UFT/QTP may be unresponsive or may halt or stop the execution.

Interestingly this screenslock creates issue with other testing tools like Selenium or TOSCA as Well. So even though this post talks about UFT,but we can apply them for Selenium or TOSCA or any other tools as well


This sample piece of code gives a mouse move which stops to activate screen saver.. Here we are simulating a mouse click just to tell the Operating system(Windows) that the machine is not free and there is an active user working on it.

Function Handle_SystemLock(Object, Method, Arguments, retVal)
Set o=CreateObject("Mercury.DeviceReplay")
o.mouseMove second(now),100
Set o=Nothing
End Function

Screensaver or Screenlock


We can use runtime co-ordinates “x” and “y” with mercury device replay feature,this should help us click on the item.

set obj=createobject("Mercury.devicereplay")
obj.mousemove xcord + somevalue , ycord+somevalue
obj.mousedblclick xcord + somevalue , ycord+somevalue,0


Screensaver or Screenlock


I have read this book posted here
This is also an interesting solution.

Dim WShShell,Value,Saved
Dim Password
'Password=Inputbox ("Enter Password")
'If Password <> "running" then Wscript.quit
Set WshShell=WScript.CreateObject("WScript.Shell")
On Error Resume Next
Value = WshShell.RegRead("HKCUControl PanelDesktopScreenSaveActive")
Saved = WshShell.RegRead("HKCUControl PanelDesktopSaveScreenSaved")
'MsgBox Value & "-" & Saved
On Error Goto 0
If Saved <> "1" then
WSHShell.RegWrite "HKCUControl PanelDesktopSaveScreenSave",Value
WSHShell.RegWrite "HKCUControl PanelDesktopSaveScreenSaved","1"
WshShell.RegWrite "HKCUControl PanelDesktopScreenSaveActive","0"
end if
and this restores it...
'::Title Restore Saved Screen Saver
'::Version 0 - Date 05 Nov 2000
Option Explicit
Dim WShShell,Value,Saved
Set WshShell=WScript.CreateObject("WScript.Shell")
On Error Resume Next
Value = WshShell.RegRead("HKCUControl PanelDesktopSaveScreenSave")
Saved = WshShell.RegRead("HKCUControl PanelDesktopSaveScreenSaved")
'MsgBox Value & "-" & Saved
On Error Goto 0
If Saved = "1" then
WSHShell.RegWrite "HKCUControl PanelDesktopScreenSaveActive",Value
WSHShell.RegWrite "HKCUControl PanelDesktopSaveScreenSaved","0"
end if

Screensaver or Screenlock


Function DisablescreenSaver()
Dim WSHShell, RegKey, ScreenSaver, Result
Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKCUControl PanelDesktop"
ScreenSaver = WSHShell.RegRead (regkey & "ScreenSaveActive")
If ScreenSaver = 1 Then 'Screen Saver is Enabled
Result = MsgBox("Your screen saver is currently active." & _
vbNewLine & "Would you like to disable it?", 36)
If Result = 6 Then 'clicked yes
WSHShell.RegWrite regkey & "ScreenSaveActive", 0
End If
Else 'Screen Saver is Disabled
Result = MsgBox("Your screen saver is currently disabled." & _
vbNewLine & "Would you like to enable it?", 36)
If Result = 6 Then 'clicked yes
WSHShell.RegWrite regkey & "ScreenSaveActive", 1
End If
End If
End Function

How to Use these codes:

Copy these lines of codes into a notepad and save the notepad as “Test.VBS” to a the test’s main directory. Either you double click on it to activate before the test or using Execute command run this file.

See also  Shall We Execute Our Automation Test case in Random Order??

How to Run Excel Macro using UFT?:

This section talks about a generic problem in our daily testing life. Say I have a scenario where I need to generate some output through UFT and based on that output I need to do some operation in Excel.

There are two ways to do that Either generate the output first to and excel and try to excel coding through UFT or simple generate the output and call a inbuilt macro that will do rest. I found the later one is the best solution…

1.I have an excell sheet that needs to be run and execute its in built macro
2. After the executed result of the macro,I need to add that output excell to UFT and start UFT execution

We were having problems as the excell sheets data are dynamic and there was a manual intervention every time when we tried to do Step-1 and Step-2 one after another. Later the solution is found..
The solution is:
Strat the QTP execution–>QTP will trigger the Macro->Then it will import the executed sheet –>do its normal execution.

The code is:

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
'Replace "macroname", "params1", "param2" with' the appropriate values
objExcel.Run "macroname", "params1", "param2"
'If there is no parameter for your macro .You can leave this place blank
objExcel.Run "macroname"

How To Use Sendkey Function in QTP or UFT or VBScript

Sendkey– the term says us that this is related to some key that needs to be sent. Now Questions are where ?? when?? how??

Consider a scenario when you need to delete a few things from your drive or you need to select all the files or you need to take a screenshot automatically through scripting.

There might be a scenario where QTP/UFT fails to record a step and still you need to automate that scenario.

How do you go through manually…yes by keying Delete key or Alt+A or by pressing PrtSc.
Right Now if the same has to done through QTP/UFT, we need to educate QTP regarding the same. Well, most of the time, we need to use sendkey function while doing an end to end Testing…I am not going in-depth of the idea… let’s go directly to the point…I am incorporating some basic codes which can be used.

Let’s check out how to write a small function that does our work…

Sub ctrlA()
//This is for Ctrl+a command
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "^"+"{a}"
set WshShell = Nothing
End Sub

Let’s see some more examples…

Sub shiftDel()
//this is for Shift delete command
set WshShell = CreateObject("WScript.Shell")
WshShell.Sendkeys "+"+"{DEL}"
set WshShell = Nothing
End Sub

Yes, you got the idea right…Now u need the list of all keys which can be sent during the runtime.
Click on the link:
to get the list of all keys that can be sent.

This is a very popular solution while working with UFT and advanced framework. Also, read VBScript Datatype for further understanding. While working with sendkeys don’t forget to use comments for readability.

Happy sending..:)

How To Enable UFT code to use Microsoft Word Spell Check

The following (QTP) code shows a function for checking the number of spelling and grammar errors in a string. This function is also used to check the accuracy of a specific property in all the objects of a given application.

Function NumberOfSpellErrors(strText) 
Dim objMsWord 
Set objMsWord = CreateObject("Word.Application") 
objMsWord.WordBasic.Insert strText 
NumberOfSpellErrors = objMsWord.ActiveDocument.SpellingErrors.Count 
objMsWord.Documents.Close (False) 
objMsWord.Quit ' close the application 
Set objMsWord = Nothing' Clear object memory 
End Function 

The following function uses the Spell errors function to check a specific property. Of all the objects with a given description which are under a given parent

Sub CheckAllObjects(ParentObj, ObjDesc, PropName) 
Dim ObjCol, idx, PropValue, OldReportMode 
OldReportMode = Reporter.Filter 
Reporter.Filter = 2 ' Report only errors 
If (IsNull(ParentObj)) Then 
Set ObjCol = Desktop.ChildObjects(ObjDesc) 
Set ObjCol = ParentObj.ChildObjects(ObjDesc) 
End If 
For idx=0 to ObjCol.count-1 
PropValue = ObjCol.Item(idx).GetROProperty(PropName) 
RetVal = NumberOfSpellErrors(PropValue) ' The actual spell check result 
If (RetVal > 0) Then 
ReportText = "Object #" & idx+1 & ": The '" & PropName & "' Property has " & RetVal & " spell errors (" & PropValue & ")" 
Reporter.ReportEvent 1, "Spell Check", ReportText 
End If 
Reporter.Filter = OldReportMode 
End Sub

How to Toggle Between Faster Mode and Normal Mode In QTP .

Normally we run all our QTP Scripts in Normal mode. This is required as Scripts might interact with web pages or Some applications (may be desktop or some other applications).

Think of some other scenarios, where our script will not interact with other application like testing painting or analog scripting testing. For those cases we don’t need not run our script in Normal mode. We can go with Faster mode.

Again there might be scenarios where our script might do some analog activity and can interact with other applications. For this mixture  applications we need to run some portion of our script in Faster mode and some part will run in normal mode.

For solving this third point we need to toggle between faster mode and normal mode.

Now how to code in QTP which will toggle between faster and normal mode..
Setting Run mode as Normal

Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Visible = True
App.Options.Run.RunMode = "Normal"
App.Options.Run.StepExecutionDelay = 100

Setting Run mode as Faster

Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Visible = True
App.Options.Run.RunMode = "Fast"


There is also one more run mode called Maintenance Mode run.

Share and Enjoy !

2 thoughts on “How To Work With Automation Object Model In UFT?

  1. Hi this is very helpful info. I have one requirement like “Need to connect the ALM in UFT and execute the script” this operation I have done using vbscript . It is worked but it run with local option in UFT , I need to run this script with First option means Test result should automatically save in ALM. If you connect the ALM in UFT we have 2 option right, vbs file always running with 2nd option means running the script in locally. Could you help me on this ?

Leave a Reply

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