Check that image is loaded
JS-step fails after running more than 15s.
view raw js-step_checkimage.js hosted with ❤ by GitHub
Force links open to the same window
view raw js-step_forcelinksopentosamewindow.js hosted with ❤ by GitHub
Select random date range with a Datepicker and a Timepicker
view raw js-step_setdatepicker.js hosted with ❤ by GitHub
Set text for an HTML element
view raw js-step_settext.js hosted with ❤ by GitHub
Wait for HTML #element to disappear
JS-step fails after running more than 15s.
view raw js-step_waitforelementtodisappear.js hosted with ❤ by GitHub
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.
view raw js-step_param_poll_not_showing.js hosted with ❤ by GitHub
Parameterizable file download
JS-step can be configured from another JS-step.
view raw js-step_param_file_download.js hosted with ❤ by GitHub
Load jQuery
External scripts need to be loaded in the same step they are used.
view raw js-step_load_jquery.js hosted with ❤ by GitHub
Check that the URL contains something
view raw js-step_checkurl.js hosted with ❤ by GitHub
Click first matching link
When having multiple links with the same content click the first match.
view raw js-step_click_first_match.js hosted with ❤ by GitHub
Scroll to the bottom of the page
view raw js-scroll_to_bottom.js hosted with ❤ by GitHub
Scroll to an element of the page
Scroll to an element by ID
document.getElementById("div").scrollIntoView();
callback (true);
In the scrollIntoview we can add properties like scrollIntoView({behavior: 'smooth'});
Useful resources:
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy
Communicate to an external server
Talking to a REST API. This example shows how data can be sent from a trace to an HTTP server in any domain.GLOBALS.saveData is posted to an external server.
view raw js-step_send_json.js hosted with ❤ by GitHub
Here’s a Node.JS example of the server that receives the data (GLOBALS.saveData), and saves it into a file. This is not a JS-step, but an example Node.JS server you can host to receive data from your traces.
view raw node-saveData-http.js hosted with ❤ by GitHub