Synthetic Agent: New experimental script commands
25th April 2024
We've added three new script commands
clearScreen
clearDocument
setValueEx
clearScreen
clearScreen
makes the contents of the current page invisible but setting it's opacity to 0
It's useful when creating scripts that navigate from one page to another but you want to blank out the initial page from the the filmstrip.
As the document still exists, it's possible to click on links and other elements in the page. Network requests that might be fired as the page is unloaded e.g. analytics data sent via sendBeacon
, will still be sent and seen in the waterfall for the destination page
logData 0
navigate %URL%
clearScreen
logData 1
navigate %ORIGIN%/about/
clearDocument
clearDocument
destroys the current page and can also be used to blank out the current page in the filmstrip when navigating from one page to another.
As it destroys the current document then it's not possible to click on links or interact with any other elements in the page.
Any network requests scheduled by sendBeacon
should fire when the current page is destroyed so they shouldn't be seen in the waterfall for the destination page – this is my main use case for it.
logData 0
navigate %URL%
clearDocument
logData 1
navigate %ORIGIN%/about/
setValueEx
Writing scripts for forms on pages that use frameworks with a Virtual DOM is verbose and can be error prone.
You might use the exec
command with a JavaScript snippet like this to complete a form field and then fire an input event to update the VDOM.
exec el = document.querySelector('[name="username"]'); proto = Object.getPrototypeOf(el); set = Object.getOwnPropertyDescriptor(proto, 'value').set; set.call(el, 'demo'); el.dispatchEvent(new Event('input', { bubbles: true }));
setValueEx
attempts to simplify the script by populating the input field and then firing both input and change events to signal it's been updated so the VDOM updates too.
In the example below the username and password fields are both set to the value of demo without needing the JavaScript snippet.
logData 0
navigate %URL%
setValueEx name=username demo
setValueEx name=password demo
logData 1
clickAndWait type=submit
This is an experimental script command
If we're happy with its reliability then we will change the main setValue
command to have the same behaviour.