The Web Scripting Engine lets you automate a web page before it shows on your screens. You can log in, scroll, hide elements, refresh on a timer, run your own JavaScript and more. This page is the full command and syntax reference.
New to scripting? Start with the Web Scripting Engine overview, then come back here for the command details. If you only need to hide a cookie banner, the Hide Cookie Banner automation does it for you without writing a script.
Before you start
A few things that will save you time:
Selectors in our examples are illustrations, not fixed values. Websites change their HTML often, and the exact selectors below may differ on the live site by the time you read this. Always copy the current selector from the page you are targeting, using the Selectors steps at the end of this page.
Logging into third-party services can be blocked. Many providers (Google and Microsoft included) detect automated logins and may require multi-factor authentication (MFA) or block the attempt. If a service enforces MFA, an unattended script cannot complete the login. Where a provider offers a native Yodeck app or a public/shareable link, prefer that over scripting a login.
Never store credentials in plain text. When a script contains a username or password, mask it. See Mask your credentials at the Scripting Engine text field.
Syntax (must read)
The syntax is intentionally simple. The rules:
Each command can be on its own line or share a line with others.
Every command must have a set of parentheses. All commands are function calls.
Integers are written as usual, for example
pause(5).Strings (selectors, URLs and text) are wrapped in triple double quotes
"""...""".
A valid string looks like this:
"""this is a string"""
Strings can span multiple lines.
Inside a string, the Scripting Engine does not support the backslash
\or the single quote'characters. This matters most for usernames and passwords. If your value contains a single quote, the script will not run.
Because single quotes are not allowed inside strings, write any JavaScript selectors with double quotes, for example document.querySelector("#email"), not document.querySelector('#email').
Available commands
waitForPageLoad
Waits for the current page to finish loading.
waitForPageLoad()
Pauses the script until the current page has finished loading. Use it to delay the next commands after navigation or a form submission.
openAndWait
Navigate to a URL and wait for the page to load.
openAndWait("""webpage""")
Navigates to the given URL, then pauses until the page has finished loading. The new page loads in the same Web Viewer, so any session data is preserved.
The webpage parameter is a string containing the URL to open.
type
Type text into an input field.
type("""selector""", """text""")
Type text into a specific field on the page. This works for text fields, text areas, username fields, password fields and similar inputs.
selector: the CSS selector identifying the field.text: the text to type into that field.
click / clickAndWait
Click an element, and optionally wait for a new page to load.
click("""selector""")
clickAndWait("""selector""")
Use this to click buttons, links, checkboxes and any other clickable element. Use clickAndWait when the click triggers navigation, and you want the script to wait for the next page.
selector: the CSS selector identifying the element to click.
refresh / refreshAndWait
Refresh the page, and optionally wait for it to load.
refresh() refreshAndWait()
Refreshes the current page. Useful for pages that update frequently. Use refreshAndWait when you want the script to wait for the reload to finish.
pause
Wait for a number of seconds.
pause(seconds)
Pauses the script for the given number of seconds.
seconds: an integer, the number of seconds to wait.
repeat
Repeat a set of commands.
repeat(times){
command_1()
command_2()
}
Repeats a block of commands in a compact, readable way.
times: how many times to repeat the block. Settimesto0to repeat indefinitely.
Example: refresh the page every minute, forever.
repeat(0){
pause(60)
refresh()
}
runScript / runScriptAndWait
Run your own JavaScript or jQuery, and optionally wait for navigation.
runScript("""your_script""")
runScriptAndWait("""your_script""")
If you are comfortable with scripting, run your own code. Use runScriptAndWait when your code triggers navigation.
your_script: a string containing your JavaScript or jQuery code.
jQuery tip: use our j alias for jQuery to avoid conflicts, or define your own:
var j = jQuery.noConflict();
extract
Keep one element, remove everything else, and move it to the body.
extract("""selector""")
Deletes all page content except the element matching selector, then moves that element to the body. This also fires a resize event, so a responsive element can adapt to the available space.
selector: the CSS selector identifying the element to keep.
blockUntilStart
Hold all commands until the page is visible on screen.
blockUntilStart()
Blocks the script until the web page becomes visible. Insert it once per script. The page becomes visible only once and stays visible, so blockUntilStart it cannot be used inside a repeat loop.
if / else if / else
Run commands conditionally based on what is on the page.
if: run a block when a condition is true.
else if: test a new condition when the previous one is false.
else: run a block when none of the conditions are true.
Each condition is a string of JavaScript that returns true or false.
Syntax: if("""ANY_JavaScript_code; return js_code_that_evaluates_to_true_or_false""")
Example: type the email if the email field exists, otherwise type the password if the password field exists, otherwise click login.
if("""return !!document.getElementById("email")"""){
type("""#email""", """your_email""")
}
else if("""return !!document.getElementById("password")"""){
type("""#password""", """your_password""")
}
else {
click("""#login""")
}
To keep credentials out of plain text in examples like this, mask them. See Mask your credentials at the Scripting Engine text field.
Examples
The examples below go from simplest to most advanced. Remember that the selectors shown are for illustration purposes only. Copy your own current selectors from the live page.
Keep a single element on screen
Webpage: https://www.worldometers.info/world-population/
# Show only one section of the page
extract("""body > div.container > div:nth-child(3) > div.col-md-8""")
Scroll a page up and down on a loop
Webpage: https://www.atptour.com/en/stats/leaderboard
# Once the page is visible, scroll 300px down ten times,
# then 300px back up ten times
blockUntilStart()
repeat(10){
runScript("""window.scrollBy(0,300)""")
pause(5)
}
repeat(10){
runScript("""window.scrollBy(0,-300)""")
pause(5)
}
Sign in to a web account (advanced)
Some pages require a login to display useful content. The example below signs in to a Google account.
This is shown as a pattern, not a copy-paste snippet. The field selectors on login pages are auto-generated and change often, and Google may require MFA or block automated logins. Copy your own current selectors from the live login page, and mask your credentials.
Webpage: https://accounts.google.com/ServiceLogin
pause(2)
type("""#identifierId""", """your_email""")
pause(1)
click("""#identifierNext""")
pause(2)
type("""password_field_selector""", """your_password""")
pause(1)
clickAndWait("""next_button_selector""")
pause(2)
If the login fields do not respond after type, the page may need an extra event fired after typing. See the Scripting FAQ for the fix, and Scripting Templates for ready-made login patterns.
Selectors
Selectors identify the elements you want to act on. Chrome and Firefox both let you copy a selector for any element.
Finding the selector using Chrome
Right-click the element you want to act on and choose Inspect.
In the DevTools panel, right-click the highlighted line and choose Copy → Copy selector.
Finding the selector using Firefox
Right-click the element you want to act on and choose Inspect Element (Q).
In the DevTools panel, right-click the highlighted line and choose Copy → CSS Selector.
Tip: Firefox selectors are usually shorter and more reliable than Chrome's. If a Chrome selector keeps breaking, try copying it from Firefox instead.
Related articles
Web Scripting Engine — overview and how to add a script
Scripting FAQ — fixes for common problems
Scripting Templates — ready-made login patterns
Useful Scripts To Use — scrolling, hiding elements, CSS injection and more
Mask your credentials at the Scripting Engine text field — keep passwords out of plain text
Webpage Recording Tool — record actions instead of writing them
Hide Cookie Banner automation (BETA) — remove cookie pop-ups automatically
Selectors
Selectors identify the elements you want to act on. Chrome and Firefox both let you copy a selector for any element.
Finding the selector using Chrome
To find the selector for a specific element or field in a web page using Chrome, do the following:
Right-click on the element you want to act upon and select
InspectRight-click in the highlighted area in the DevTools panel and select
Copy → Copy selector
Finding the selector using Firefox
To find the selector for a specific element or field in a web page using Firefox, do the following:
Right-click on the element you want to act upon and select
Inspect Element(Q).Right-click in the highlighted area in the DevTools panel and select
Copy → CSS Selector
Note: Firefox CSS selectors are usually shorter and more accurate.


