Executing Script¶
Sometimes it is necessary to execute JavaScript on the page to successfully automate an action. In other cases, an expression needs to be evaluated based upon the current state of the page. To solve these two conditions, use the "ExecuteScript" action.
For Example:
...
- FindElementsByXPath:
Take: 1
Patterns:
- //*[@id="main-content"]/fieldset/form/div[6]/div/button
- ExecuteScript:
Script: "arguments[0].click(); return 'testing';"
ResultVariableName: testingvar
Arguments:
- ArgumentType: Element
- ExecuteScript:
Script: "return arguments[0] == 'testing';"
Arguments:
- ArgumentType: SerializedValue
Value: '{testingvar}'
ResultVariableName: ClickResult
- Click
ConditionGroup: ClickResult
Nearest: Any
Patterns:
- Sign In
...