playwright-observe
Reads the current screen of an open browser session and returns the accessibility snapshot, in which every element carries a ref such as e40. Those refs are the handles the action commands take, and every reading reassigns them, so never reuse a ref from an earlier reading.
You do not need this after acting. Every action command, playwright-resize and playwright-open each return the screen as it stands afterwards, in their own observation field, so act on a ref from the row the previous command returned. Call this to look again without doing anything - after a wait, or when a row's snapshot was not enough.
A screen you have not seen is read from the outside in, starting at depth=3. That returns the page's outline - its top-level containers and their refs - and passing one of those refs as target reads inside that one container, narrowing again with depth if it is still large. Ask for the whole tree instead and a console page arrives cut off at the row limit, having spent the room on whatever the page happens to list first.
Once you know what you are looking for, text or regex returns only the matching part of the tree, which is cheaper still. Whichever way you narrow, line_count says whether the reading held more than you were shown.
- session-id=VALUE
- Required. Browser session to read. e.g. the session_id returned by playwright-open
- text=VALUE
- Optional. Return only the parts of the tree containing this text, matched as a case-insensitive substring. Cannot be combined with regex. e.g. 차단 정책
- regex=VALUE
- Optional. Return only the parts of the tree matching this regular expression. Case sensitive unless wrapped in slashes with flags. Cannot be combined with text. e.g. /save|submit/i
- depth=VALUE
- Optional. Include only this many levels of the tree, 1 to 30. Use it to see the page's outline and the containers worth descending into. e.g. 3 - where to start on a screen you have not read before
- target=VALUE
- Optional. Read only this element and what is inside it, named by a ref from an earlier reading. e.g. e18
- after=VALUE
- Optional. Start the snapshot just past this element instead of at the top of the tree, so a reading that arrived cut off can be continued. Pass the next_after value from the previous row. e.g. e120
- limit=VALUE
- Optional. Return at most this many lines of the snapshot, 1 to 5000. Combine with after to page through a large screen. e.g. 200
Output Fields
| Field | Type | Name | Description |
|---|---|---|---|
| session_id | String | Session id | e.g. 6f1c2a08-6c1e-4a1b-9a5e-9b2f0d3c7e11 |
| url | String | URL | e.g. https://fw.example.com/policy/list |
| title | String | Page title | e.g. Policy - Firewall Console |
| element_count | Integer | Element count | e.g. 42 - number of addressable elements on screen, whether or not a search was asked for |
| match_count | Integer | Match count | Set only when text or regex was given; 0 means the screen does not show it. e.g. 3 |
| settle_ms | Long | Settle time | e.g. 4500 - milliseconds waited for the page to stop changing |
| observation | String | Observation | Accessibility snapshot with one ref per element, or just the matching parts when text or regex was given. e.g. - button "Save" [ref=e45] |
| line_count | Integer | Line count | Lines the whole reading holds. Larger than what you were shown means the row was cut off - continue with after, or narrow with target or depth. e.g. 504 |
| next_after | String | Next after ref | Set when the reading was cut by limit; pass it back as after to continue. Absent once the end is reached. e.g. e120 |
| error | String | Error | Set only when the site refused the reading. e.g. navigation timeout |