Runs the given script and outputs a sequence of strings. This action can both output values and select elements (see Remarks). If the browser needs to return to the state produced by this action, it won't run the script again, so it should be used with scripts that collect values or select elements, but don't modify the DOM or change the state of the page in any way. To run a script that changes the state of the page, use RunScript instead.
Browser.EvalScript · [script] · [argument]
- The script to run.
- The argument to pass to the script, which will be accessible from within the script as the
A sequence of strings.
This function returns a sequence of strings, which makes it possible to control its output values, the elements it selects, and the number of times the action below will run. Depending on the type of data returned by the script, the following rules can be used to control the behavior of this action:
- string/boolean/number: Outputs a string representation of the value.
- element: Selects this element on the browser.
- If the object contains a property called element, it selects the element on the browser.
- If the object contains a property called value, it outputs its value as a string.
- list: It performs the actions specified by the rules above for each element on the list. Actions below this action will run for each list item.
Returning null, undefined, or not returning any value will cause it to output "null" and run the action below once.
The rules above can be used to perform useful operations, and control the execution flow in many ways, such as the following:
- Returning a string will output the string as is and keep the state of the browser unchanged.
- Returning an empty list will cause it to skip the actions below.
- Returning a list of strings will output each of the strings on the list and run the action below for each of them. The state of the browser will remain unchanged.
- Returning a list of elements will select each of the elements on the list, and run the action below while each element is selected.