Scripting FAQ

Common problems you may run into with the Web Scripting Engine, and how to fix them. For the full list of commands, see the Scripting Engine Reference.

Two reminders that prevent most issues:

  • The selectors in these examples are placeholders. Copy your own current selector from the live page using the steps in Selectors.
  • Never leave a password in plain text. Mask your credentials before you save.

I can’t log in; the credential fields don’t seem to register

You typed the right username and password, but the site rejects the login, or the fields stay empty. Modern sites often ignore values typed by a script until the field fires an event. Add an event after the type command.

Most sites:

type("""username_css_selector""", """my_username""")
pause(1)
type("""password_css_selector""", """my_password""")
pause(1)
runScript("""
document.querySelector("username_css_selector").dispatchEvent(new Event("change"))
document.querySelector("password_css_selector").dispatchEvent(new Event("change"))
""")
pause(1)
click("""login_button_css_selector""")

React login forms. If you see the words react or reactApplication in the page source, the field needs its value set through React’s own setter, then an input event. Use this instead:

runScript("""
var emailField = document.querySelector("email_css_selector")
var nativeSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set
nativeSetter.call(emailField, "my_username@email.com")
emailField.dispatchEvent(new Event("input", { bubbles: true }))

var passwordField = document.querySelector("password_css_selector")
nativeSetter.call(passwordField, "my_password")
passwordField.dispatchEvent(new Event("input", { bubbles: true }))

document.querySelector("login_button_css_selector").click()
""")

Some dashboards need an input event that bubbles, fired after type:

type("""email_css_selector""", """email""")
pause(1)
type("""password_css_selector""", """password""")
pause(1)
runScript("""
document.querySelector("email_css_selector").dispatchEvent(new Event("input", { bubbles: true }))
document.querySelector("password_css_selector").dispatchEvent(new Event("input", { bubbles: true }))
""")
pause(1)
clickAndWait("""login_button_css_selector""")

The page loads blank or is only partly loaded

Some pages keep loading content after the first render, so a script that acts immediately sees an empty or half-built page. Give the page time, then act.

  • Add a pause after navigation, for example pause(5).
  • Use waitForPageLoad() after openAndWait so the script waits for the load to finish.
  • Use blockUntilStart() once at the top so commands only run after the page is visible on screen.
openAndWait("""https://example.com/dashboard""")
waitForPageLoad()
pause(5)
extract("""your_content_selector""")

If the content only appears after scrolling, scroll the page first. See Useful Scripts To Use for scrolling examples.


My script runs before the page is ready

This is the same root cause as a blank page: timing. Order your script so it waits for the page.

  • After openAndWait, add waitForPageLoad().
  • Add pause(seconds) before commands that depend on content being present.
  • Use blockUntilStart() once, near the top. It holds every command until the page is visible. It cannot go inside a repeat loop, and it should appear only once.

The element I need is inside an iframe

If the content sits inside an iframe (common with embedded dashboards, maps and players), a normal selector on the outer page will not find it. Two options:

  • Point the Web Page media straight at the iframe’s own URL. Open the page, right-click the embedded content, and look for the iframe’s src URL. Using that URL directly is the most reliable fix and often removes the need for a script at all.
  • If you must stay on the outer page, note that scripts cannot reach into an iframe loaded from a different domain. This is a browser security rule, not a Yodeck limit.

Click the accept button so the banner closes before your content shows.

pause(4)
click("""accept_button_selector""")

For step-by-step help finding the right button, see How to remove the cookie pop-up from your web page media. To skip scripting entirely, try the Hide Cookie Banner automation (BETA).


The login needs MFA or two-factor and never completes

If the service asks for a one-time code or app approval, an unattended script cannot complete it because there is no person to approve the prompt. Your options:

  • Check whether the provider offers an app password or a service account that does not require MFA for this use.
  • Use a native Yodeck app for that service if one exists. Apps are built for unattended use and do not break the way scripted logins do.
  • Where the data can be shared by a public or read-only link, point the Web Page media at that link instead.

My script worked before but suddenly stopped

The site changed its HTML, so the selector your script relies on no longer matches anything. This is the most common cause of a script that used to work.

  • Recopy the selector from the live page using the Selectors steps.
  • Prefer selectors based on a stable id over long chains of auto-generated class names.

My selector is very long or keeps breaking

Long selectors full of random-looking class names (for example div.aCsJod.oJeWuf) are auto-generated and change whenever the site is rebuilt. They break often.

  • Copy the selector from Firefox rather than Chrome. Firefox selectors are usually shorter and more reliable.
  • If the element has an id, target that directly, for example #main-content.

My password contains a single quote or a backslash

The Scripting Engine does not support the single quote ' or the backslash \ inside a string, including usernames and passwords. If your credential contains either character, the script will not run. Where possible, change the credential to remove those characters, or use an account that does not contain them for the signage login.