Modifying options for script execution
Some scripting framework options that affect script execution can be specified through the user interface. Values that you set in the user interface persist as the default values from script to script. However, you can also use the scripting framework to set some of these options directly in the functional 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 com.rational.test.ft.script.IOptionName
interface.
See the HCL OneTest™ UI API Reference for information
about the com.rational.test.ft.script.IOptionName
interface.
To retrieve the current value of an option, use the getOption
method
as follows:
Object x = getOption(IOptionName.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.option,value);
You must specify a value of a type that applies to the option.
The HCL OneTest™ UI IDE has a Content Assist feature that can be
helpful here. In the earlier example, after entering IOptionName
,
press Ctrl+Space, or click from the menu.
A list of all the options open. 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.
With the scripting framework, 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.DELAY_BEFORE_KEY_DOWN, 0.3);
InputWindow().inputKeys("abcdefg123");
resetOption(IOptionName.DELAY_BEFORE_KEY_DOWN);
InputWindow().inputKeys("999");