Execute JavaScript application actions

Use the Execute JavaScript application actions to run custom JavaScript in either the built-in Chromium browser or on a Desktop Automation Service host in Edge (running in IE compatibility mode).

The custom JavaScript code is free to interact with the web page and has access to the full JavaScript context.

  • The JavaScript code is executed through the equivalent of the eval() function.

  • If the Wait For Result option is selected, the Robot waits for the code to complete and returns the completion value of the JavaScript code, similar to the eval() function. This value is converted into text as described for either browser.

  • If the Wait For Result option is not selected, the step completes immediately, while the script runs in the background. In this case, the JavaScript Execution Result variable will be empty.

  • If a Robot needs to return more complex data, have the JavaScript code serialize data into JSON. Then have the Robot deserialize data back into a JSON variable using the parse() function.

  • For all Execute JavaScript application actions, configure the JavaScript Execution Result field to include a variable option that may or may not return a value from the script.

Most Robot steps automatically execute relevant JavaScript as part of their operation, so you generally do not need to use the Execute JavaScript application actions unless you have special needs for executing JavaScript.

For example, the Execute JavaScript application action provides an easy way to change the website in a Robot and to edit the HTML using querySelector, compared to Basic Engine Robots, which you can edit using Predefined JavaScript Polyfills.

For additional Execute JavaScript content in RPA Help, see also "Windows step" Application actions and "Access websites " Application actions.

The scope of the RPA documentation does not include instructions for JavaScript programming or manipulating web pages. If you are unfamiliar with JavaScript's nodes, elements, and selectors, refer to tutorials and resources available online. For example, search for "online HTML editor" to find resources, then look for HTML DOM and CSS.