Set Test Setting and Options runtime


Sometimes, you may need to change the test settings during runtime. For example, you need to set the maximum time that UFT allows when loading a Web page or retrieve the same to make use of it further in your automation. It’s the setting option Browser navigation timeout under Web tab.

Test Settings

Another example could be, when you need to change synchronization timeout setting for a specifc scenarion at runtime and want to revert it back for other scenarios  or you need to change other run setting options as you see in the snapshot below. These could be related to datatable, resources, iteration etc.

 Run Iteration

In UFT, we have the Setting object to control how UFT runs tests by setting and retrieving testing options during a run session.  This is an Utility Object which enables you to modify test settings during the test run. The test settings can be understand as global variable with dictionary of keys and their values, where the values can be set or retrieved.


Setting Object Properties

Item: can be used to set or retrieve the value of given setting.


For example,to retrieve Iteration mode from run setting


Below are some of the available KeyNames

DefaultTimeout : Use this key to change/retrieve the maximum time to wait if the object is not found. The time should be in miliseconds.

WebTimeout : Maximum time in milliseconds to wait before it is determined that a URL address cannot be found.

AutomaticinkRun : This Key determines whether automatically created checkpoints will be executed during the test run or not. Its Value can be either True or False.

True: Automatic checkpoints are executed.

False: Automatic checkpoints are not executed.

DefaultLoadTime: : Use this key to change/retrieve the amount of time it should wait for a page to load during the run session. The time should be in seconds.

SnapshotReportMode :  Indicates when the images are captured. The value can be one of the following:

0 – always captures images.

1 – captures images only if an error occurs on the page.

2 – captures images if an error or warning occurs on the page.

3 – never captures images.

Default = 1.

Tools> Options > Gui Testing > Screen Capture

 Screen capture

You can get the full list of available KeyNames that you can use to change or retrieve the settings and options. Just Click on Generate Script button at Settings dialog (Test > Setting) and Options Dialog (Tools > Options) as shown in the snapshots below. Once you save the scripts, just open it (no need to run, open it in any file editor). You will find the list of KeyNames and their usage in each statement.


 Setting Generate Script



WebPackage: Webpackage poperty enables you to set or retieve values relevant for the web add-in.

Setting.WebPackage(“Key Name”)

Some of the possible keys or setting options that can be used are as below

ReplayType : this setting option is to change the way mouse operations should happen on AUT. It can be either browser events or mouse event.  Browser event is similar to DOM events using the Browser methods, wheras Mouse event simulate the actual user action either from keyboard or mouse. For example if you click on a button when ReplayType is Mouse, you will notice that mouse pointer moves to the location of button and fires the event, but n case of browser event it doesn’t.

Values of replaytype can be

1 – Event

2 – Mouse

By default it is set to Event i.e 1


Setting.WebPackage("ReplayType") = 2

 Replay Type

RunUsingSourceIndex : Indicates whether the source index property should be used. The value can be one of the following:

0 – Does not use the source index property to identify objects.

1 – Uses the source index property to identify objects


Setting.Packages.WebPackage.Settings("ReplayUsingSourceIndex") = 0

Setting Object Methods

Add Method

Using this method, you can add a user-defined settings and use it further in your scripting.

For example, In some cases you need to turn off a particular recovery option and again you want that to be enabled. In this situation you can have setting created and use it as required.


Exists Method

Before creating a new user defined settings, it is always a good practice to check it has aready been created earlier or exists already.

If Settings(RecoveryEnabled) =Yes then Settings(RecoveryEnabled) = No Else Settings.Add RecoveryEnabled, Yes bEnabled = Settings.Item(RecoveryEnabled) End if

Remove Method

Once you are done with the test or there is no scope for the user defined  settings in the current test, You should always Kill it by using the Remove method.

Settings.Remove “RecoveryEnabled”

Hope this was helpful, Please provide your feedback/quiestions via the comments below.



  1. Hey Saket:

    Thank you so much. Your QTP papers really help me to pass QTP certification Exam.

    Now, I came to the next step of looking for a job in QA field.

    I have a question, do you suggest me any site where I can get practice Test cases. This is because I would like to write various types of Test cases to get confidence when I’ll go for job.

    Also, I’ll look for Interview questions on your site.

    I will definitely recommend your site to all my friends.

    Priti Naidu

  2. Hi Saket,Is there any way to call object spy ,spy object,add it to repository etc through scripting…
    plz help me in this regard….

    • Hi Vinay,
      You can definitely add objects to object repository and manipulate existing objects in repository using scripting. Use Mercury.objectRepositoryutil object. here is sample. I will surely plan to post more details around this.refer QTP help.

      Set myRepository = CreateObject("Mercury.ObjectRepositoryUtil")
      oRepository.Load ""
      0Repository.AddObject oButton, Browser("").Page(""), "ButtonName"

  3. Do while ((Browser(“Micclass:=Browser”).Page(“Micclass:=Page”))<>”complete”)
    its giving error like

  4. I think the issue is an extra bracket you have used, which might be causing the error.
    try below ..

    Do while (Browser(“Micclass:=Browser”).Page(“Micclass:=Page”).Object.ReadyState<>”complete”)

  5. Hi Saket,
    i used the same code but am getting Object Disable Error.
    Do while (Browser(“Micclass:=Browser”).Page(“Micclass:=Page”).Object.ReadyState”complete”)

    • GetRowwithCellText – gives you the row number of a cell with specified text in it. e.g. consider the table below

      Sr. Name Amt
      1 ABC 100
      2 STU 750
      3 XYZ 102

      you need to find the row number in which 750 is present. GetRowwithCellText method gives you the row number directly without using loops to go through each and every cell data.

      whereas GetCellData is used to retrieve the data in a specified cell. e.g in the table above if you need to retrieve the content from row 2, col 3. you need to use GetCelldata method.

  6. Browser(“Micclass:=Browser”).Page(“Micclass:=Page”).Link(“name:=Here”).Click
    If Browser(“Micclass:=Browser”).Page(“Micclass:=Page”).Exist Then
    End If
    ‘object disable error
    Browser(“Micclass:=Browser”).Page(“Micclass:=Page”).WebRadioGroup(“html id:=ProfileTypeDet2”).Select “N”
    If Browser(“Micclass:=Browser”).Page(“Micclass:=Page”).Exist Then
    End If
    ‘object disable error
    Browser(“Micclass:=Browser”).Page(“Micclass:=Page”).WebList(“html id:=subscriberCat”).Select “CONSUMER”
    If Browser(“Micclass:=Browser”).Page(“Micclass:=Page”).Exist Then
    End If
    ‘object disable error
    Browser(“Micclass:=Browser”).Page(“Micclass:=Page”).WebList(“html id:=subscriberSubCat”).Select “Standard”


  7. Hi Saket.. Good POst.. how to set “Save MOvie to Results” option in uft “screen capture” window while I am running script using “setting” object.As per “generate Script” file option is “MovieCaptureForTestResults” I didnt find this in any keys.. Please help


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.