Execute JS
Last updated
Last updated
This element is intended for running JavaScript code in the browser. It can be used to change page contents, to interact with data, and to emulate user actions.
It is recommended to use this element inside a container: Open Browser or Attach Browser. Browser type should be specified in the container.
Symbol *
in the property name means that it is required. Description of common properties can be found in the Element properties section.
«Process» group:
Script*. String. Enter here the script that needs to be executed. Note that quotation marks inside the string should be escaped. If the script declares a function, the following template should be used: "function test(a, v, el) { alert(v); return null; }"
. Where v - is an argument.
Time-out*. Int32. Maximum waiting time for process completion (ms). By default it is set to 10000
.
«Function» group:
Function. Boolean. Mark this checkbox if the script contains a function. By default the checkbox is not marked.
Argument. String. Works only with the Function property enabled. Use this field to specify the argument of the function. An argument can be a specific value (for example, "hello"
), or a string variable. Only one argument can be used.
Search pattern. This property is used to select the web page control where the script will be run. Use Magic wand tool to create a search template quickly. More information about search patterns can be found here. Requires a browser extension.
Control. LTools.WebBrowser.Model.IElementInfo. In this property you can specify a variable that contains a reference to a web control.
How to get it:
In the script first use the Element exists component. In the Control output property of this component, specify a variable of the UIControl type - it will store a reference to the control.
In the Control property of the Execute JS component, open the code editor and specify <variable name>.BrowserElement
.
«Output» group:
Result. String. Variable for storing the script execution result.
Below is an example of using the element in the Pure code type process: