JavaScript examples

Examples for js-step. See also Variables for a global variable support in JavaScript steps.


Check that image is loaded

JS-step fails after running more than 15s.


Force links open to the same window


Select random date range with a Datepicker and a Timepicker


Set text for an HTML element


Wait for HTML #element to disappear

JS-step fails after running more than 15s.


Parameterizable poll to make sure an element is not visible

JS-step can be configured from another JS-step. Use case example: create a trace which has only this JS-step. Then, in other traces you can reuse this JS-step multiple times by setting the parameters before calling the trace.


Parameterizable file download

JS-step can be configured from another JS-step.


Load jQuery

External scripts need to be loaded in the same step they are used.


Check that the URL contains something


Click first matching link

When having multiple links with same content click the first match.


Communicate to external server

Talking to a REST API. This example shows how data can be send from a trace to an http server in any domain. GLOBALS.saveData is posted to an external server.

Here’s a Node.JS example of the server that receives the data (GLOBALS.saveData), and saves it into a file. This not a JS-step, but an example Node.JS server you can host to receive data from your traces.