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, andscreenshotare the action names.url,waitUntil,selector, andtypeare arguments. They configure how the action runs.status,text, andbase64are 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.
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
| Action | What it does | Returns |
|---|---|---|
goto | Navigate to a URL | status, time |
click | Click an element | x, y, time |
type | Type text into an element | time, selector |
select | Select an option from a dropdown | value, selector |
text | Extract visible text from an element | text |
html | Extract raw HTML from an element | html |
screenshot | Capture a screenshot | base64 |
solve | Solve a CAPTCHA | found, 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.