For AI agents: a documentation index is available at /llms.txt
Skip to main content

BQL Language Basics

Learning a new language can be intimidating, but mastering BQL doesn't have to be difficult. This guide provides a straightforward overview of how to write BQL with clear examples.

BQL Script Structure

A BQL script is one mutation block containing one or more actions. Actions run in order, top to bottom. Each action has a name, optional arguments that configure it, and response fields that define what data it returns.

mutation ScriptName {
goto(url: "https://example.com", waitUntil: domContentLoaded) {
status
}
text(selector: "h1") {
text
}
screenshot(type: png) {
base64
}
}
  • goto, text, and screenshot are the action names.
  • url, waitUntil, selector, and type are arguments. They configure how the action runs.
  • status, text, and base64 are response fields. They define what data gets returned.

Find all available actions, arguments, and response fields in the BQL API Reference or the Built-in Documentation in the IDE.

Aliases

Because a BQL script is a single mutation block, every action name must be unique. If you use the same action twice, BQL cannot distinguish them in the response.

This fails:

mutation LoginForm {
goto(url: "https://practicetestautomation.com/practice-test-login/") {
status
}
type(selector: "#username", text: "student") {
time
}
type(selector: "#password", text: "Password123") { # ❌ duplicate action name
time
}
click(selector: "#submit") {
time
}
}

Fix it by prefixing each duplicate action with an alias:

mutation LoginForm {
goto(url: "https://practicetestautomation.com/practice-test-login/") {
status
}
typeUsername: type(selector: "#username", text: "student") {
time
}
typePassword: type(selector: "#password", text: "Password123") {
time
}
click(selector: "#submit") {
time
}
}

Aliases also become the keys in the JSON response, making the result easier to parse.

For GraphQL readers

In GraphQL terms, each action is a mutation field on the root mutation type. Aliases are required because GraphQL does not allow duplicate field names within the same selection set.

Core Actions

ActionWhat it doesReturns
gotoNavigate to a URLstatus, time
clickClick an elementx, y, time
typeType text into an elementtime, selector
selectSelect an option from a dropdownvalue, selector
textExtract visible text from an elementtext
htmlExtract raw HTML from an elementhtml
screenshotCapture a screenshotbase64
solveSolve a CAPTCHAfound, solved, time

For the full list of available actions and their arguments, see the BQL API Reference.

Next Steps

BrowserQL simplifies web automation with intuitive commands and a structure that's easy to learn. Explore these key areas to build more sophisticated automations:

Frequently Asked Questions

What query language does BrowserQL use?

BrowserQL uses GraphQL. Queries are structured as mutations that navigate, click, type, wait, and extract data from web pages. Each mutation runs sequentially against a live browser session.

How do I navigate to a page in BQL?

Use the goto mutation with a url parameter and a waitUntil condition such as load, domcontentloaded, or networkIdle. This ensures the page is ready before running subsequent mutations.

Can I chain multiple actions in a single BQL query?

Yes. BQL mutations run sequentially in the order you write them. You can chain goto, click, type, wait, and extraction mutations in a single query to automate multi-step workflows.