get_state returns Playwright's AI snapshot: the ARIA tree with a ref on each element (e12, and f1e3 inside a frame). Without include the providers ask for all, the outline and a screenshot, or tree when the call takes no images, as in code mode (browser.built_in.with_include), on the built-in browser and on Chrome and Edge alike.
Playwright versions
Playwright 1.60 serves it as Frame.ariaSnapshot(mode="ai", track), one text that is incremental when the same document has an earlier tracked snapshot; earlier versions serve Page.snapshotForAI, which returns both.
Whole or changes
The driver asks for the whole page when the document is new or a full read is wanted, and otherwise only for the changes.
Marks
Changed lines are marked <changed> and [unchanged] stands for what was already sent.
Limits
Password field values are redacted from both, and a page is cut at 40,000 characters.
Refs
Item
Lifetime
Playwright resolves aria-ref=<ref> against its latest snapshot, and a ref stays the same for as long as its element exists, so refs survive any number of actions and turns.
Kept
The driver keeps each ref's role and name from the snapshots.
Lookup
A ref that no longer resolves is looked up by that role and name, and so is an element named directly by role and name.
Failure
If that still finds nothing, the action fails with element_gone, which the model reads as ELEMENT_GONE, and the page as it is now. An element that has no box on the page, for a press-and-hold click or a click at its centre, fails the same way before any input is sent.
User's browser
In the user's Chrome or Edge a ref goes to Playwright MCP as it is, and role with name goes as the locator getByRole(role, { name, exact: true }), which its target accepts beside a ref. A locator that matches several elements fails with ambiguous_element, one that matches none with element_gone, and an element action that names nothing with target_required before anything is sent.
Acting
Item
Input
Clicks, hovers, key presses, type_text (insert_text at the caret, fill with clear: true), set_value (select_option, set_checked or fill), drag_to and set_input_files are Playwright's own trusted input. In the user's Chrome or Edge, type_text inserts through a page script at the caret.
Background tabs
They reach a tab in the background without bringing it forward, which was checked against the App: a background tab receives isTrusted pointer, mouse and click events.
Scrolling and paste
Scrolling uses page_actions.SCROLL_SCRIPT, and paste uses PASTE_SCRIPT.
Coordinates
A click by x,y maps screenshot pixels to CSS pixels with the ratio measured when the screenshot was taken, if the screenshot is still current (Coordinates).
Cursor
Before a click, the App's agent cursor is armed and placed on the element.
Navigation
After an action, the driver waits up to 0.3 s for a navigation to start.
Load
If one starts, it waits for domcontentloaded.
Requests
It then waits up to 2 s for fetch/XHR requests the action started.
Return
Then it returns the changes, or the whole page when the URL changed or the document is new.
Exception
An exception becomes a result with a reason code and the page as it is now, never a raw error.
Approval. The App's tabs need none: opening or navigating to any site, acting on it and running a script in it ask nothing.
upload_file is never covered by the Page grant: the modes that ask ask and Auto reviews it, on every call; code mode's validator refuses it; the read-only actions (list_tabs, get_state, find, wait, read_console_messages, read_network_requests) are marked as reads for the broker.
File upload
Item
Hidden inputs
Pages rarely show their file input: it sits behind a styled upload button with display: none, so the outline has only the button, or the page creates the input when the button is clicked.
Approach
The driver therefore uploads the way a person does, as Playwright MCP does.
Listener
Every write action runs with a filechooser listener on the page (_catch_choosers), which makes Chromium hand the chooser to the driver instead of opening a window on the user's screen; the listener is removed when the action has settled, so the user's own clicks open the usual window.
Caught chooser
A chooser caught that way is kept on the tab and the result carries file_chooser (multiple, accept); upload_file(path) without an element answers it, a bad path leaves it waiting, and any other write drops it.
One step
upload_file(element, path) is the one-step form.
Set or click
When the element is a file input or the label of one (FILE_INPUT_SCRIPT), the file is set on that input, hidden or not; anything else is clicked inside expect_file_chooser and the chooser it opens takes the file, or the call fails with no_file_chooser after 3 s.
No guessing
The driver never guesses an input near a button: a page with a second hidden input would take the file into the wrong field and report success, which is also why Codex exposes uploads only through the chooser.
Causes
The page may be stuck in an earlier upload, or open its input only after an await that spent the click's user activation.
Error
So the error says what the button reads now and whether it is disabled (ELEMENT_STATE_SCRIPT), and lists the page's enabled file inputs, numbered (FILE_FIELDS_SCRIPT).
Entry
Each entry gives its id or name, accept, multiple, the text it sits in, and whether it is the only one in the button's section.
Choice
The model picks one with upload_file(field=n, path), which sets the file on that input (Tab.file_fields).
Dropped
Any other write action, or a new page, drops the list, and the user's own browser does not support field.
Text result
The text result names a caught chooser and its accept, so the model knows to answer it.
User's browser
The user's Chrome or Edge follows the same model through Playwright MCP's own file-chooser state: upload_file with an element clicks it first, without one it answers the chooser the last click opened.
Drop zones
Drop zones with no file input at all are not covered.
evaluate
Item
Reach
evaluate reads everything a signed-in page holds, including what snapshots redact.
Grant
It is part of operating its browser: in the built-in browser it runs under the Page grant, and in the user's Chrome or Edge under that browser's grant (computer_use(browser chrome), computer_use(browser edge)).
Mark
page_script marks a computer_use browser call with an evaluate step (single or in actions); the policy uses the mark for one thing, refusing such a call in a turn someone other than the owner started (IDENTITY_PAGE_SCRIPT: outside MCP clients, agents or schedules someone else set up) or one that works from text the owner did not write (IDENTITY_OUTSIDE_TEXT: a handoff, an automatic Goal).
Code mode
Code mode's validator applies the same test (identity.unattended, identity.outside_text) to an evaluate step of a code call.
Card
A card that asks about a call with a script shows the arguments untruncated.
Redaction
The result passes the same password redaction.
Element
With element (a ref, or role and name), a function script receives that element as its argument.
Forms
A function script is called; any other script runs as a console runs it, parsed first as an expression, else as statements whose last value is the result, else (with await) as the body of an async function whose return is the result, so it runs once; a promise it returns gets 30 s (SCRIPT_SECONDS).
Errors
A script that throws fails with script_error and the page's own message.
Caps
Scripts are capped at 8000 characters and results at 20,000.