Modifying options for script execution

Some options that affect script execution can be specified through the user interface. Values set in the user interface persist as the defaults from script to script. You can, however, also set some of these options directly in the test script, for example, the amount of time between keystrokes.

A programmatically set value only lasts until the end of playback. After playback ends, the option reverts to the default value. Constants for these options are defined in the Rational.Test.Ft.Script.IOptionName_Fields interface. See the HCL OneTest UI API Reference for more information about this interface.

To retrieve the current value of an option, use the GetOption method as follows:


     Dim x As Object = GetOption(IOptionName_Fields.option

You can test the value of x to determine whether you want to change the option value during playback. To do so, use the SetOption method, which has the following general format:


     SetOption(IOptionName_Fields.option, value)

You must specify a value of a type that makes sense for the option. The Visual Studio.NET IDE has an IntelliSense feature that can be helpful. In the example above, after entering IOptionName_Fields, press Ctrl+Space, or select Edit > IntelliSense from the menu. This brings up a list of all the options. You can use the arrow keys to scroll through the list, or type the first few letters of the option name if you know it. When you press Enter, the currently selected option name is inserted into your script.

You can also reset the value of an option back to the default value by using the ResetOption method. For example, to change the delay between keystrokes during playback for a short time, you can script a sequence like this:


     SetOption(IOptionName_Fields.DELAY_BEFORE_KEY_DOWN, 0.3)
     InputWindow().InputKeys("abcdefg123")
     ResetOptionOptionName_Fields.DELAY_BEFORE_KEY_DOWN)
     InputWindow().InputKeys("999")