Execution and Language Context Built-ins¶
Sets and accesses Context Objects.
A common execution context is used to store all variables that belong to a scenario. All languages can store and retrieve objects using getContextObject
and setContextObject
. By default, a single global context is shared between all intaQt sublanguages (UI Steps and Steps), but the sublanguages can be isolated using the Legacy Configuration. An example of a feature file using isolated contexts is at the bottom of this section.
Set Context Object¶
Sets the context object.
Syntax
1 | setContextObject(<name String>, <value Any>) |
Parameters
-
name - The specified variable name
-
value - The value assigned to the context object
Example
1 | setContextObject("counter", 0) |
Get Context Object¶
Retrieves the context object.
Syntax
1 | <contextObject contextObject> := getContextObject(<name String>) |
Returns
The context object, or null
if the specified variable does not exist.
Parameter
- name - The specified variable name
Stepdef Example
1 2 3 4 5 6 7 | stepdef "use context" a := getContextObject("counter") if a = null then setContextObject("counter", 0) a := 0 end end |
Feature File Example
1 2 3 4 5 | Feature: Counter Scenario: TestExecutionContext Given use context And verify counter == "0" |
Get Execution Context Object¶
Gets the execution context object.
Syntax
1 | <result Any> := getExecutionContextObject(<name String>) |
Returns
The retrieved object.
Parameter
- name - The context object's name
Example
1 | aParty := getExecutionContextObject("AParty") |
Accessing Context Objects with Language Isolation Configured ¶
If intaQt is configured to isolate the sublanguages, then execution context objects can be accessed from within Feature Files by prefixing the variables with the web.
or soap.
prefix.
For example, the counter
variable in the example above can be accessed by soap.counter
if setContextObject
was used in a Steps file:
1 2 3 4 5 | Feature: Counter Scenario: TestExecutionContext Given use context And verify soap.counter == "0" |