Execute JavaScript

This action executes JavaScript on the current page, or your own custom JavaScript.

Note that most step actions will automatically execute relevant JavaScript as part of their operation, so you generally do not need to use the Execute JavaScript action unless you have special needs for executing JavaScript.

The Execute JavaScript action supports the following ways in which HTML can contain JavaScript:

  • <script>-tags, which can contain multiple lines of JavaScript to be executed, or can refer to external JavaScript files.
  • event handlers, which may appear as special attributes on tags, and they always begin with "on," such as, onClick or onMouseOver. They may also be attached from JavaScript without being visible in the HTML source.
  • JavaScript URLs, which specify the JavaScript: Protocol with values for tag attributes where there can be a URL, such as <a href="javascript:open()">

Properties

The Execute JavaScript action can be configured using the following properties.

JavaScript

This property specifies which JavaScript you want to execute:

  • JavaScript in All <script> Tags executes all of the <script>-tags in the current page.
  • JavaScript in Selected <script> Tag executes a single found <script>-tag.
  • JavaScript in URL executes the JavaScript in a JavaScript URL, as specified by the JavaScript: Protocol.
  • JavaScript in Event Handler executes the JavaScript in an event handler in a tag. The specific event handler that should be executed must be chosen from the drop-down box.
  • Custom JavaScript executes your own custom JavaScript.
  • Custom JavaScript from Expression executes your own custom JavaScript. This is similar to the Custom JavaScript option, except that an expression can be entered instead of a fixed text. For a list of JavaScript functions check Convert Using JavaScript
Continue when
Add a wait criterion for the step. If you have several wait criteria, execution stops when any wait criterion is met. You can have several met wait criteria such as if you are waiting for two HTML elements that appear on the same load, or if you are waiting for an element on the main frame, and Initial Page Load Completes is set. For more information, see Use Wait Criteria.
Options

The robot's options can be overridden with the step's own options. An option that is marked with an asterisk in the Options Dialog will override the one from the robot's configuration. All other options will be the same as specified for the robot.