Back to FAQs

Can I call a JavaScript function or extract a value from the page itself?

Sure thing! Browser Bots can run arbitrary JavaScript code inside the browser with Evaluate Blocks.

Evaluate Blocks, or eval blocks, are similar to Code Blocks except that they run inside the browser, while code blocks control your script’s from execution outside the browser. Because eval blocks run inside the browser, they have access to the DOM and to variables and functions within the page itself.

One use for eval blocks is to write custom validation, throwing an error if expected content on the page isn’t found.

var welcomeMessage = document.querySelector('.welcome-message');

if (!welcomeMessage) {
    throw new Error("No welcome message found after logging in!");

Learn more and check out the examples in Evaluate Blocks.