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

Log In with BQL and Browser Automation

Automate a login flow (navigating to the login page, filling credentials, solving CAPTCHAs, and handling post-login redirects) using BQL or a Puppeteer/Playwright connection.

Prerequisites

Steps

Use the REST API to automate a login flow without a persistent browser connection.

View Full Code on GitHub

1. Build the BQL mutation

Chain navigation and interaction steps. The agent resolves selectors dynamically from a snapshot of the page:

https://production-sfo.browserless.io/chromium/bql?token=YOUR_API_TOKEN_HERE

2. Send the request

curl -X POST \
"https://production-sfo.browserless.io/chromium/bql?token=YOUR_API_TOKEN_HERE" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation AgentLogin { goto(url: \"https://app.example.com/login\") { status } waitForSelector(selector: \"input[type=email], input[name=email], #email\") { selector } typeEmail: type(selector: \"input[type=email], input[name=email], #email\", text: \"user@example.com\") { time } typePass: type(selector: \"input[type=password]\", text: \"YOUR_PASSWORD\") { time } solve { found solved } submit: click(selector: \"button[type=submit]\") { time } waitForNavigation { status } }"
}'

3. Check the output

{
"data": {
"goto": { "status": 200 },
"waitForSelector": { "selector": "input[name=email]" },
"typeEmail": { "time": 134 },
"typePass": { "time": 98 },
"solve": { "found": false, "solved": false },
"submit": { "time": 76 },
"waitForNavigation": { "status": 200 }
}
}

Next steps