browserscale MCP server

Model Context Protocol endpoint (Streamable HTTP), version 1.0.0.

Endpoint: /mcp

Auth: Authorization: Bearer <your-api-key>

Docs: browserscale.cloud/docs

Sessions

Looking

Acting

Memory

Docs

Sessions

sessions

List the browser sessions running on the API key, with sessionId, country, exit IP, minutes left and what this server recorded of them. Use it to pick up a session a program or an earlier conversation rented, including one a failed run left behind with its page still showing. Maps to SDK ListBrowsers.

rent

Rent a browser session and open its first tab. Pass the returned sessionId to every other tool. A session is billed by use while it runs; minutes is only the limit after which it ends on its own, so stop it when the work is done. With your own proxy (proxyHost, proxyPort and its credentials), country, timezone and language follow its exit IP, and a proxy that doesn't connect fails the rent. Without one the session gets a managed proxy in the country asked for, a random one without, where the deployment has managed proxies; PROXY_SERVER_NOT_CONFIGURED says it has none. The result has the live-view link where the user can watch the browser and take it over. Maps to SDK RentBrowser.

stop

End a session: the browser closes with everything in it, and billing stops. Returns what the session used. Stop the sessions you rented once the work is done, unless the user wants the page kept open. A stopped session's history stays readable for a while. Maps to SDK StopBrowser.

tabs

The session's tabs and popups. A link or script that opens a new tab or popup brings it to the front, like in a desktop browser, and closing one hands the front back, usually to the page that opened it. list shows every tab with its pageId, URL and title, which one is in front and which opened which. switch brings a tab to the front, like clicking it. open opens a new tab in front. close closes a tab; a session keeps at least one. Maps to SDK Pages, CreatePage, Page.Focus and Page.Close.

Looking

navigate

Open a URL in the tab. Returns when the new document commits, before the page's JavaScript has built anything: wait for what the next step needs before you observe or act. Maps to SDK Page.Navigate.

observe

Read the tab as compact text: URL, title and scroll position, then one line per visible element of every frame with its number, attributes, live value and flags. Each frame's header carries a '# ref @d1' line: a row's number followed by that, e.g. 47@d1, is the element's ref, which any tool takes as its target, in whichever frame it is. The way to look at a page and to check a step's result. It doesn't wait. Scope follow-up looks to the part you work on. Maps to SDK Page.GetObservation.

screenshot

See the tab as a person would. Use it when layout, images, a captcha or an error you can't place matter; observe is cheaper otherwise. Maps to SDK Page.Screenshot.

wait

Wait until one of the conditions holds and learn which one, and for an element its ref and the frame it is in. A css condition is looked for in every frame, a js condition runs in the main document; 'in' confines either to one frame or one part of the page, per condition. Use it after every navigate and every step that changes the page, racing the outcomes the step can have: the next page's field, an error message, a challenge. A js condition matches when its value is truthy (e.g. location.pathname === '/step-2'); an element must be visible and holding still. On timeout it reports per condition how far it got. Maps to SDK Page.Wait.

evaluate

Run one JavaScript expression in the tab's main document, or in the frame or element 'in' names, and get its value, or the ref when it returns an element. For what the other tools don't give: proving a target (how many elements a selector matches), testing a js locator or wait condition, reading app state or data the observation doesn't show, fetching from the page's own API. A promise is waited for and the result is what it resolved to, so fetch(...).then(r => r.json()) and await work. URL, title, inputs and text are in observe, waiting for the page is wait's, and clicking or setting values through it skips the real input events pages and bot checks look for (click and fill send them). Maps to SDK Page.Evaluate, Page.EvaluateIn and Page.EvaluateWith.

network

The session's network traffic: what the browser requested and got back, as recorded since this server knows the session. It shows what a click or a form really sent, finds the JSON API behind a page (often a cleaner source than the page itself), and tells why a step failed when the page doesn't say. list shows the exchanges since the last action, grouped by the call they followed, without page assets unless asked and with a crowd of requests to other sites (analytics, ads) summed up per host; get shows one in full with the headers and kept bodies of both sides; search finds text in URLs, headers and bodies; start and stop change what is captured. A session rented here records from its first request. Maps to SDK StartNetworkCapture, StreamNetworkExchanges, ReadNetworkBodyRange and StopNetworkCapture.

Acting

click

Click an element like a person would: human pointer path, scrolled into view, held still, and checked that the point belongs to the target. A css target is found in whichever frame it is, iframes included; 'in' confines it to one frame, one dialog or one component. If something covers it, the error names it. Returns the ref of the element it hit and its frame. Maps to SDK Page.Click.

fill

Click a field and type into it key by key like a person would, so the page's validation runs. Appends to what's there unless clearFirst. Stays bound to its field: if something takes focus mid-way it stops instead of typing elsewhere. Maps to SDK Page.Fill.

type

Type text key by key into whatever has focus, without pinning a field, so the page may move focus while typing: code boxes that advance per digit. Click the first field first. Waits for a captcha solve that is running. Maps to SDK Page.Type.

press_key

Press and release one key on whatever has focus: Enter to submit, Tab to move on, Escape, the arrows, or a shortcut with modifiers. Maps to SDK Page.PressKey and Page.ReleaseKey.

select

Pick an option of a <select> directly, without the pointer, by exactly one of value, text or index. Fires input and change like a person's pick. Maps to SDK Page.SelectByValue, SelectByText and SelectByIndex.

hover

Move the pointer onto an element on a human path without pressing, for menus and tooltips that open on hover. Maps to SDK Page.MoveTo.

scroll

Scroll an element into view, to reach content that loads on scroll or to bring a part of the page on screen for a screenshot. click, fill and hover scroll to their target themselves. Maps to SDK Page.ScrollTo.

solve_captcha

Solve the interactive challenge in the tab (checkbox, slider, image grid, ...) in whichever frame it is, and get the token. Call it when a wait's captcha condition matched or you see one; a page without a widget has nothing to solve and only costs the timeout. Maps to SDK Page.SolveCaptcha.

sdk_call

Call any method of the Go SDK by name, for everything the other tools don't cover. Page methods (DragBy, DragTo, InsertText, reactions, GetDOM, ReadCanvas, LoadHTML, ...) run on the tab; CloudBrowser methods (cookies, storage, auth sessions, proxy, captcha auto-solve, request interception, usage, ...) on the whole session. A method both have runs on the tab; write browser.AddReaction (or browser.ListReactions, browser.RemoveReaction) for the session's, which covers every tab. Pass the arguments in order, without ctx. Locators are JSON as in click, and where a method takes a place to look in (EvaluateIn, an observation's Scope) the object can name a frame itself, e.g. {'frameUrl': '*pay*'}; option structs are objects with the Go field names. A wrong call returns the method's real signature, and docs_read api-reference/go-index.md lists every method. The TypeScript SDK has the same methods in camelCase.

steps

Run several tool calls in a row on one session with one call: a stretch you already know, such as filling a form's fields, or an action together with the wait that follows it. It stops at the first step that fails and returns every step's result, so batching loses nothing. Single calls stay the better choice where the next step depends on reading the result of the one before.

Memory

history

What was done in this session through these tools, in order. flow shows each call with what it acted on or waited for and how it went, and marks where a script would need a wait the calls didn't have. go and ts show the same calls as the lines a browserscale-go or browserscale-ts program contains: the material for turning what worked into a script, for comparing with a script that misbehaves, or for telling the user exactly what was done. echo makes every later result carry its own line, for writing code along the way.

Docs

docs_read

Read a page of the browserscale docs, or one section of it. Paths are relative to the docs root as README.md lists them (e.g. guides/captchas.md); guide.md is the manual for these tools, quickstart.md the program around the SDK calls, api-reference/go.md and ts.md every method. Long pages return their table of contents; read a section then.

Search all browserscale docs pages for words. Returns matching lines with page, line and section.

Prompts

browser_task

Get something done in a browser. Hand over a task to be done on the web in a real browser: look something up, fill something in, go through a flow.

browser_script

Turn a flow into an SDK script. Work a flow out in a real browser, then get it as a Go or TypeScript program on the browserscale SDK.

browser_debug

Debug a browserscale program. Find out on the real page why a program on the browserscale SDK misbehaves.

Guide sent to the client

# Driving browserscale browsers These tools drive real Chromium browsers in browserscale's cloud. Each tool is one call of the browserscale SDK, named in its description, so what works here works the same in a Go or TypeScript program, and the server can hand any stretch of work back as that program's lines. The browser does the waiting, the targeting and the human-like input itself. You say which state you need or which element you mean, and it reports the moment that holds, in which frame, and if it didn't, why not. So there is little to poll and nothing to rebuild from raw DOM queries. Every call is a round trip, and round trips are what the work costs. A stretch you already know goes into one `steps` call: navigate, wait and observe, or a form's fields, the click and the wait for its outcomes. Call a tool on its own only when the next call depends on what it shows. ## The short version 1. `rent` a session, or take a running one from `sessions`, and pass its `sessionId` to every call. 2. `navigate`, then `wait` for what you expect to see, then `observe` to read the page. 3. Act with `click`, `fill`, `select` and `press_key`, through targets taken from the observation. 4. After every step that changes the page, `wait` again and race the outcomes the step can have: the next page's field, an error message, `{"captcha": true}`. 5. `network` shows what a step sent and got back. `history` shows what was done, as a flow or as SDK code. 6. `stop` the session when the work is done. ## Three kinds of work The same tools serve all three, a conversation often moves between them, and nothing has to be declared. - **A task to get done.** Someone wants something looked up, filled in or carried through on the web. The outcome is what counts: take the direct way, and say what you did and found in the user's terms. Targets only have to hold for now. - **Help with a program on the SDK.** The user's code misbehaves, or they are writing it. `sessions` lists what runs on their key, and a session their program rented can be attached to while it runs or after it failed, with the page as the program left it. Check the code's locators against the real page, read the traffic, try the failing step: the errors here carry the codes their code gets. Answer in SDK calls; `docs_read` has the reference for both languages. - **A flow that becomes a script.** Work it out here; `history` with `go` or `ts` then gives the calls that worked as source lines and marks where a wait is missing. Here targets have to hold tomorrow and in every language the site comes in, and every step needs its wait. ## Sessions - `rent` starts a session and opens its first tab. Every other tool takes the `sessionId` it returns. `sessions` lists what runs on the API key, so you can pick up a session a program or an earlier conversation rented, also one a failed run left behind and still shows its page. Attaching doesn't disturb what runs in it. - A session is one isolated browser with its own cookies, storage, cache, proxy and fingerprint. It is billed by use while it runs; the minutes given to `rent` are only the limit after which it ends on its own. `stop` what you rented once the work is done, unless the user wants the page kept. - With your own proxy, country, timezone and language follow its exit IP, and a proxy that doesn't connect fails the rent. Without one the session gets a managed proxy in the country you ask for, a random one without, where the deployment has them. `PROXY_SERVER_NOT_CONFIGURED` says it has none: ask the user for a proxy then. Proxy providers often take options in the username, such as a country or a session id for a sticky IP; pass the username as the provider documents it. - `rent` returns a live-view link. There the user watches the browser and can take it over with mouse and keyboard. ## Tabs and popups - Each page tool acts on one tab: the one you name with `pageId`, otherwise the one in front, which is what a person would be looking at. - The browser behaves like a desktop one: a link with `target=_blank`, a `window.open` or a sign-in or payment popup opens a new tab that comes to the front, and closing one hands the front back, usually to the page that opened it. - A result carries a `Tabs:` line when tabs opened, closed or came to the front during the call, and with several tabs open it says which one the call went to. What happened between two calls shows in the next result as `Since the last call:`. `tabs` list shows the current state. - Clicks and what builds on them (fill, type, keys, dragging, hovering) only reach the tab in front, as for a person. Such a call on a tab behind fails with `page_not_focused` and names the tab in front; nothing was pressed. Go on there with its `pageId`, or bring yours forward with `tabs` switch. ## The loop: act, then wait A flow is a chain of steps, and between most of them the page has work to do. `wait` marks every point where the page has to get somewhere. - `navigate` returns when the new document commits, before the page's JavaScript has built anything. Follow it with `wait`, then observe or act. - On a page you don't know yet, wait for what you expect to see, or with a JS condition such as `document.readyState === 'complete'`. Once you know the page, wait for the element the next step needs. - Size the timeout for the step: a slow signup page gets 25 s, a toast 5 s. The default is 30 s. - After every step that submits, loads or switches a view, wait again and race the outcomes the step can have. The first condition to hold wins, and the result says which: conditions count from 0 in the order given, as the SDK's result does. - Conditions are watched inside the page, so a match comes back right away. CSS conditions are re-checked whenever the document changes; prefer them where they work. - A JS condition covers state CSS can't express: `location.pathname.startsWith('/welcome')`, an app flag, a text match. It matches as soon as its value is truthy. If it returns an element, that element has to be visible and holding still, like a CSS condition (`visible: false` and `steadyMs` change that). A JS condition that throws counts as false until the timeout, without an error, so test it once with evaluate before relying on it. - An element that has to be visible also has to be reachable: when it lies in the viewport, a wait checks nothing covers it. A button behind a consent banner doesn't match, and the timeout says `found_occluded` with the banner as occluder. - Prefer the destination over "something changed": `location.pathname === '/step-2'` also holds at the end of a redirect chain. After a click that should leave the page, race a condition the old page can't meet. - `click` and `fill` find their own target for up to 5 s. That covers an element rendering a moment late within a page, not a page load or a server answering a form. - Polling with evaluate or sleeping does worse than `wait`: it is slower, and it misses states that come and go. - A timed-out wait reports per condition how far it got: `not_found`, `found_hidden`, `found_occluded` (with the element on top), `pending_steady` (still moving) or `not_seen` (a request or response that never came). Each needs a different fix; read it before trying again. - `steps` stops at the first step that fails. Its refs are from before the batch: once a step loads another document, the refs after it are `stale_ref`, so target what follows with css or js, or end the batch there and look. ## Looking at the page - `observe` is the first look at every page and the cheap re-look after every step. It lists what a person can see, plus what can be acted on. Its headers carry URL, title and scroll position. Each frame's section starts with a `# ref @d1` line, and each line is `tag#id[number]`: the number and the frame's `@d1`, as `47@d1`, are the element's ref. A line carries `role`, `type`, `name`, `placeholder`, the live `value` (passwords as a length), `href`, `frameId` on iframes, then flags, then the text in quotes: - `click`: interactive (controls, links, roles, click handlers, pointer cursor). - `offscreen`: an interactive element outside the viewport. - State: `checked`, `expanded` (a menu, accordion or details is open), `pressed`, and the flags `selected`, `current`, `invalid`, `focused`, `disabled`, `required`, `readonly`. A range or number field carries `min`, `max` and `step`. - `hidden="reason"`: interactive but not seeable, e.g. a checkbox styled away behind its label. Nothing else that can't be seen is listed. - `inert`: in plain sight but takes no clicks, as everything behind a modal dialog does. `no-pointer-events`: a click there goes to what lies underneath. - `newtab`: a link that opens another tab. - `shadow`: the lines below it sit in this element's shadow root, where CSS from outside doesn't reach. - `id-not-unique` / `id-not-selectable`: the id is duplicated, so `#id` is ambiguous or hits another element; don't target by that id. - `aria-label` shows where it says more than the text. `autocomplete` and a `data-testid` no other element shares are anchors for a script. - A select shows how many options it has, followed by one `option` line each with its `value` and `selected`. A long one lists the first 60 (`options="249" shown="60"`); observe with the select as scope lists all. - `scroll="y=1200-1800/8400"`: the element scrolls its own content and shows 1200 to 1800 of 8400. `scroll` to its last item brings on what follows. - A canvas or video line carries only its `size`; what it shows takes a screenshot. - The quoted text at the end is the label or text, never the value. - A header line `# on top: div#consent[60] covers 100% of the viewport` says that a dialog or consent layer lies over the page, and clicks land on it until it is dealt with. Its lines carry `on-top`. - Rebuilding that with evaluate (URL, title, lists of inputs, buttons or links, body text) costs more and shows less. - After the first full look, scope follow-ups to what you work on: observe with `scope` (the form, or one frame) or `viewportOnly`. Above a `# budget spent` line the frame is complete; below it only interactive elements, headings, iframes and what is on top are listed. Scope the look or raise `maxTotalTokens` to read the rest. - Observe doesn't wait. If the page may still be building, wait first. - `screenshot` when layout, an image, a captcha or an error you can't place matters. ## Targets that survive - A target is an object with one of `css`, `js` (an expression returning the element), `ref` (an element you saw, e.g. `47@d1`) or `at` (`[x, y]`), plus optional `in`, `visible` and `steadyMs`. - Pick the target while the observation is in front of you. For a script, pick one that holds in every language the site comes in and on the next load. Language-free first: `name`, an id without the id flags, `type`, `autocomplete`, `data-testid` and other data attributes, the path of a link or form (`href`, `action`), `role`; then the structure around such an anchor (`form#signup button[type=submit]`, `#results li:first-child a`). Ids or classes a build or a counter made (`css-1kq8x2`, `Button_root__3xK9a`, `ember412`, `:r5:`) change with the next deploy or load, and so do positions. - Text is the last resort for a script. What an element says and the attributes that carry text (`aria-label`, `placeholder`, `title`, `alt`, a button's `value`) follow the session's language, and most sites come in several. Matching text to find your way once is fine; a target that goes into a script matches text only when nothing else tells the element apart, then covers every variant the script will see. - CSS takes the first rendered match, passing over hidden copies such as the one in a closed menu (the result says when it did), and can't match text. Where text is the only way, use a JS locator, e.g. `[...document.querySelectorAll('button')].find(b => /Weiter|Next|Suivant/.test(b.innerText))`. - The action returns the ref of the element it hit and names its frame; compare it with the observation to prove the target is right. - A `ref` is the surest target for a one-off step: it names exactly the element you saw, in whichever frame. It ends with its document: after a navigation or reload the call fails with `stale_ref` instead of hitting something else, so look again. A script takes refs from its own results, or uses css or js. Waits can't take ref or at conditions. - Shadow DOM: CSS doesn't cross shadow roots. Put the host in `in` (`{"css": "button.next", "in": "date-picker"}`), or use `__wrc.shadow(host)` in a JS locator, which returns a host's shadow root, open or closed. - Frames: a css target is looked for on the whole page, the main document first, then every frame, cross-origin ones and ones created later included; the result names the frame it was found in. A js target runs in the main document only. `in` says where to look instead: an iframe by `css`, `js` or `ref` (its document), a frame by `frameUrl` (a wildcard), `frameName` or `frameId`, `{"main": true}`, `{"any": true}` for every frame, or any other element for its subtree. Several containers form a list from the outermost in: `"in": [{"frameUrl": "*shop.example/*"}, {"css": "iframe.pay"}]`. A call waits for its containers as it does for its target; one that never comes is `container_not_found`, naming the missing link. - In a wait every condition has its own `in`. A css condition on the whole page, one inside the payment frame and a js condition about the main document's `location` race together without affecting each other. A captcha condition looks in every frame. ## Acting - `click` moves the pointer on a human path, scrolls the target into view, waits for it to hold still and checks the point belongs to the target before pressing. If something covers it, it re-aims once at an exposed part, then refuses and names the element on top. It never presses whatever lies on top. - `fill` focuses the field with the same click, then types key by key with real key events on the session's keyboard layout, so the page's validation runs and buttons gated on input get enabled. It appends; `clearFirst` replaces. It stays bound to its field: if something takes focus mid-way it stops instead of typing elsewhere. - For code boxes that move focus on every digit, click the first box and use `type`: the same real key events, but it lets focus move. - `InsertText` (via sdk_call) commits text at once without key events; a button gated on typing stays disabled. - `select` sets an option directly, without the pointer. `press_key` presses and releases one key on whatever has focus. `hover` moves the pointer onto an element for menus that open on hover; `scroll` brings an element into view. - Clicking or setting values through evaluate doesn't do what it seems to: synthetic events have no pointer path and bot checks flag them, and assigned values don't fire the events the page listens for. Removing elements with evaluate to get a click through leaves the page in a state no visitor has. ## What may or may not appear - Consent banners, newsletter modals and similar: register a reaction right after navigate with sdk_call `AddReaction`; its css target is watched for in every frame. It clicks the element with the same click as `click` once it shows up and removes itself; an action running then pauses at a safe point (a click before it presses, a fill between two keys) and carries on after it. `AddReactionWith` with `On` clicks another element, such as the close button. A click blocked by a modal lands once the reaction has closed it. A banner that can come on any tab or popup goes on the session: `browser.AddReaction` arms it on every tab, the ones opened later included, and it fires once on each. Every click shows in a `Reactions:` line of the result of the call it happened in; a click that failed is used up too. - Captchas: put `{"captcha": true}` into the wait after every step that can bring a challenge. When it wins, take a screenshot, call solve_captcha, then wait for the step's outcomes again. Without a challenge solve_captcha only costs its timeout, so call it when you have seen one. Passive bot checks need nothing. - For challenges that can come anywhere, also in the middle of an action, sdk_call `EnableCaptchaAutoSolve` with `{}` once per session: the browser then solves every challenge on every tab as it appears. A click, fill, type or drag it interrupts is held and carries on afterwards, and its result says so. Solves during a call also show in a `Captchas:` line. While a wait with a captcha condition runs on a page, auto-solve leaves that page alone, so the step's own handling wins. - A "verify you're human" page without a widget is not a captcha; the cause is usually the proxy or the country, and a new session in another country often gets through. ## The network log - A session rented here records its traffic from the first request: every request of every frame, worker and redirect hop, with the headers as sent on the wire. Bodies of text responses such as HTML and JSON are kept; `capture` on rent changes that. - `network` after a step lists what completed since the last action, grouped by the call it followed. Page assets are left out, and when a page sent many requests to sites other than the tabs' own, mostly analytics and ads, those are summed up per host; `types` and `url` bring either back. That shows what a click or a submit really sent and what came back, and it is the quickest way to tell why a step did nothing. - `get` shows one exchange in full, with the kept bodies of both sides. `search` finds text across URLs, headers and bodies: where a token comes from, which call carries an id. - Many sites load their data from JSON APIs. The response in the log is often a cleaner source than the page, and the request shows how a script could ask for it. - A session rented elsewhere is read along from the moment you attach, and only if its owner captures. `start` arms a capture there, which replaces the owner's. - The log is for what happened. For a call still to come, race it in a wait: `{"request": "*/api/login*"}` or `{"response": ...}`, with `*` spanning any characters. Calls run one after another, so such a wait only catches a call the page makes without your doing anything, such as a poll or one sent a moment after loading. sdk_call reaches the rest: `WaitForAnyRequest` / `WaitForAnyResponse` return the next matching call, `ModifyRequest` changes one, `SetBlockList` blocks URLs. ## History and code - `history` is what was done in the session through these tools, in order. As `flow` it reads as what happened: each call, what it acted on or waited for, how it went, where the page was. It marks actions that followed another with only looking in between: there you saw the page was ready, and a script has to wait for it. - As `go` or `ts` it is the same calls as the lines a program on the SDK contains. Failed calls are comments, and calls that only looked are left out. They are what was tried, in order, not a finished program: keep what the flow needs, add the waits marked as missing and the handling of the outcomes you saw. `docs_read quickstart.md` has the frame around them. - `echo` (on rent or history) appends each call's line to its result, for writing code along the way; observe and screenshot have none. - The history and the network log are this server's memory of the calls made through it. Calls a program made aren't in them, and they start over after about an hour without a call or when the server restarts. Every tool works without them. ## Working with the user - Before a step that can't be undone, such as paying, sending, deleting or publishing, say what you are about to do, unless the user asked for exactly that. - Logins, passwords and codes are the user's. Ask for them, or hand over the live-view link: the user signs in there themselves, and you carry on once a wait for the signed-in state holds. `GetAuthSession` / `SetAuthSession` (sdk_call) carry a signed-in login into a later session. - When a site turns the session away, say so and what would change it (another country, the user's own proxy) rather than trying the same thing again. - At the end say what was done, and whether the session is stopped or still running. ## Evaluate For what the other tools don't give: - Proving a target before relying on it: `document.querySelectorAll('input[name=email]').length` should be 1. - Testing the exact expression you'll use as a JS locator or wait condition. - Reading app state or data the observation doesn't show. - Asking the page's own API: `fetch('/api/items?page=2').then(r => r.json())` runs with the page's cookies and origin. One expression; wrap statements as `(() => { ...; return x })()`. When it returns an element you get its ref. With `in` it runs in a frame's document, or with an element as `__wrc.scope`. A falsy answer is a result; an expression that throws or doesn't compile is an error with code `threw` or `not_run`. A promise is waited for, and the result is what it resolved to; a rejected one is `threw`. `await` can be used directly: the expression then runs as the body of an async function, where one expression is the value and several statements end with `return`. The wait ends after 30 s with `timeout` (`timeoutMs` changes it), and the promise goes on in the page, so running it again starts the work a second time. For work that takes long, start it with `noAwait` and keep the promise, `window.job = crawl()`: the call returns at once, and `window.job` evaluated later waits for it and gives its result. A page that navigates away while an expression waits ends it with `document_gone`. ## sdk_call and state - Page methods run on the tab (`pageId`, else the one in front); CloudBrowser methods on the whole session. A method both have runs on the tab; prefix it with `browser.` for the session's. - Arguments go in order, without ctx. Locators are the same objects as `target`; option structs are objects with the Go field names, e.g. `["AddReactionWith", [{"css": "#consent"}, {"On": {"css": "#consent .accept"}}]]` as method and args. - A wrong call returns the method's real signature with the fields of its option structs. `docs_read api-reference/go-index.md` lists every method, the API reference and the guides explain them, and `docs_search` finds a word across all of it. - Cookies and local storage can be read and written as data, without a page open: `GetCookies`, `SetCookies`, `GetStorage`, `SetStorage`. `GetUsage` reports what the session consumed so far. ## Errors A failed call comes back in one of two kinds, and the difference is the retry decision: - A typed error: the browser carried the command out, but the page wouldn't go along. It has a stable `code`, details, and the meaning of the code for that method. Fix the step or branch on it; the message text can change, the code doesn't. - A plain error without details: the session, the connection or the call itself is the problem (an ended session, a malformed argument). A closed tab is its own case; see Tabs and popups. What the details tell you: - An occluder (click, fill, drag, or a wait's `found_occluded`) names the element on top: tag, id, class, text, bounds. `Position` `fixed` or `sticky` means it stays put, so scroll the target out from under it; otherwise close it through its real control or a reaction. An occluder with opacity 0 or hidden that still takes clicks (`HittableWhileInvisible`) is an invisible layer. - `focus_stolen` on fill names the element that took focus, often a popup or consent button to deal with first. - `net_error` on navigate carries the network error's name, which tells a bad proxy from a bad host. - With auto-solve on, `captcha_failed` on click, fill, type or drag means a challenge held the action and couldn't be solved; `busy` on InsertText or press_key can mean a solve is running.