Using the gomez_control APIs

The control scope can be used for storing variables that can be reused at a later point in the script's execution. An API is available that enables you to store a value that was captured or evaluated within a Target Window within the control scope as a global variable. There is also an API that enables you to set a variable in the Target Window from the control scope.

This scripting method can be used whenever you need to pass a value from the Target Window to the control scope, or vice versa.

Use this scripting method when you need to specify a conditional step within the script, to skip actions if some content is present or not present on the page. In this case, you can create one custom action to perform any JavaScript necessary against the page DOM and a second custom action to modify the script properties based on the findings in the DOM. This requires passing some value from the Target Window to the control scope, to create the conditional step.

Using this scripting method

The gomez_control APIs provide an easy way to create a variable within a different window or scope.

To create a variable in the control scope from within a Target Window, use the following syntax:

gomez_control.setVar(<name>, <value>)

where:

  • <name> is a string specifying the name of the variable.

  • <value> is the value for that variable.

For example:

gomez_control('myDate', new Date());

To create a variable within a Target Window from within the control scope, use the following syntax:

gomez_control.setVarToWin(<name>, <value>, <targetWindow>)

where:

  • <name> is a string specifying the name of the variable.

  • <value> is the value for that variable.

  • <targetWindow> is a string value of the name of the target window in which to store the variable.

For example:

 gomez_control.setVarToWin('myBooleanValue', true, 'gomez_top[0].frames[3]');