Set Options Programmatically

Relevant for: GUI tests and scripted GUI components

Use the Setting object in the Editor to control how UFT runs tests by setting and retrieving testing options during a run session.

Set an option using the following syntax:

Setting (testing_option) = new_value

To change an option, insert the Setting object statement at a relevant point in the action, such as after a specific page opens. Then, insert another statement with the Setting object to reset the changed setting before the next part of your test.

The defined setting remains in effect until it is changed again, either by another Setting statement or my modifying an option in the UI, or until the end of your current UFT session.

Note: If you make and save other changes in a related Options or Settings dialog box pane, the settings defined by the Setting statement are saved for your next session.

For detailed information on all the available methods and properties for the Setting object, see the Utility Objects section of the UFT Object Model Reference for GUI Testing.

Example:  

Setting options for an entire test

If you run the following statement with the Web Add-in loaded:

Setting("AutomaticLinkRun")=1

UFT disables automatically created checkpoints in the test.

This is the same as selecting the Ignore automatic checkpoints while running tests or components option in the Web Advanced pane of the Options dialog box.

If you run the following statement:

Setting("WebTimeOut")=50000

UFT automatically changes the amount of time it waits for a Web page to load before running a test step to 50000 milliseconds.

This is the same as setting the Browser Navigation Timeout option in the Web pane of the Test Settings dialog box.

Setting options for a specific section of a test

If you want to change the DefaultTimeOut testing option to 5 seconds for objects on one Web page only, insert the following statement after the Web page opens in your test script:

'Keep the original value of the DefaultTimeOut testing option
old_delay = Setting ("DefaultTimeOut") 
'Set temporary value for the DefaultTimeOut testing option
Setting("DefaultTimeOut")= 5000

To return the DefaultTimeOut testing option to its original value at the end of the Web page, insert the following statement immediately before linking to the next page in the script:

'Change the DefaultTimeOut testing option back to its original value.
Setting("DefaultTimeOut")=old_delay

See also: