Page Analysis
Fast, structured alternatives to screenshots for understanding page content. These tools return JSON data and require no mutex, making them ideal for multi-agent workflows. ## firefox_get_page_state Get structured page state as JSON. Returns headings, links, buttons, inputs, images, and landmarks with counts. Much faster than screenshots for understanding page content. ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `tabId` | number | active tab | Target tab ID | | `maxHeadings` | number | `30` | Max headings to return | | `maxLinks` | number | `50` | Max links to return | | `maxButtons` | number | `30` | Max buttons to return | | `maxInputs` | number | `30` | Max inputs to return | | `maxImages` | number | `20` | Max images to return | | `timeout` | number | `150000` | Request timeout in ms (5000-300000) | ### Example ```js const state = await firefox_get_page_state({ tabId: 42 }); // Returns: // { // url, title, viewport, // errors: [...], // headings: [{ level, text }], // links: [{ text, href }], // buttons: [{ text, selector }], // inputs: [{ type, name, value, placeholder }], // images: [{ alt, src }], // landmarks: [{ role, label }] // } // Limit results for large pages const compact = await firefox_get_page_state({ tabId: 42, maxLinks: 10, maxButtons: 5 }); ``` ### Tips - Prefer this over `firefox_screenshot` when you need to understand page structure without visual inspection. - Save the result to use with `firefox_diff_page_state` for change detection. --- ## firefox_get_accessibility_snapshot Get an accessibility tree snapshot. Returns the semantic structure of the page with roles, names, and states. Capped at 200 nodes by default. ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `tabId` | number | active tab | Target tab ID | | `maxDepth` | number | `5` | Maximum tree depth to traverse | | `maxNodes` | number | `200` | Maximum nodes to include (lower = faster) | | `selector` | string | `body` | CSS selector for root element | | `timeout` | number | `150000` | Request timeout in ms (5000-300000) | ### Example ```js // Full page accessibility tree const tree = await firefox_get_accessibility_snapshot({ tabId: 42 }); // Focused snapshot of a specific section const nav = await firefox_get_accessibility_snapshot({ tabId: 42, selector: "nav.main-menu", maxDepth: 3 }); ``` ### Tips - Use `selector` to scope the snapshot to a specific region for faster results. - Lower `maxNodes` when you only need a high-level overview of the page structure. --- ## firefox_get_element Get detailed information about a specific element, including attributes, computed styles, visibility, and position. ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `selector` | string | **required** | CSS selector for the element | | `tabId` | number | active tab | Target tab ID | | `timeout` | number | `150000` | Request timeout in ms (5000-300000) | ### Example ```js const info = await firefox_get_element({ selector: "#submit-btn", tabId: 42 }); // Returns: attributes, computed styles, bounding rect, visibility state ``` ### Tips - Useful for debugging why a click or type command isn't working (e.g., element is hidden or off-screen). - Check the bounding rect to verify the element is within the viewport. --- ## firefox_diff_page_state Compare two `getPageState` snapshots to see what changed. Reports added, removed, and changed headings, links, buttons, and inputs. Useful for verifying that actions had the expected effect. ### Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `before` | object | **required** | First `getPageState` snapshot | | `after` | object | **required** | Second `getPageState` snapshot | | `timeout` | number | `150000` | Request timeout in ms (5000-300000) | ### Example ```js // Capture state before an action const before = await firefox_get_page_state({ tabId: 42 }); // Perform an action await firefox_click({ selector: "button.load-more", tabId: 42 }); await firefox_wait_for({ selector: ".new-items", tabId: 42 }); // Capture state after const after = await firefox_get_page_state({ tabId: 42 }); // Diff the two snapshots const diff = await firefox_diff_page_state({ before, after }); // Returns: { added: {...}, removed: {...}, changed: {...} } ``` ### Tips - Combine with `firefox_wait_for` between snapshots to ensure the page has settled. - Useful for regression testing: capture a baseline, perform actions, and verify expected changes.Fast, structured alternatives to screenshots for understanding page content. These tools return JSON data and require no mutex, making them ideal for multi-agent workflows.
firefox_get_page_state
Section titled “firefox_get_page_state”Get structured page state as JSON. Returns headings, links, buttons, inputs, images, and landmarks with counts. Much faster than screenshots for understanding page content.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
tabId | number | active tab | Target tab ID |
maxHeadings | number | 30 | Max headings to return |
maxLinks | number | 50 | Max links to return |
maxButtons | number | 30 | Max buttons to return |
maxInputs | number | 30 | Max inputs to return |
maxImages | number | 20 | Max images to return |
timeout | number | 150000 | Request timeout in ms (5000-300000) |
Example
Section titled “Example”const state = await firefox_get_page_state({ tabId: 42 });// Returns:// {// url, title, viewport,// errors: [...],// headings: [{ level, text }],// links: [{ text, href }],// buttons: [{ text, selector }],// inputs: [{ type, name, value, placeholder }],// images: [{ alt, src }],// landmarks: [{ role, label }]// }
// Limit results for large pagesconst compact = await firefox_get_page_state({ tabId: 42, maxLinks: 10, maxButtons: 5});- Prefer this over
firefox_screenshotwhen you need to understand page structure without visual inspection. - Save the result to use with
firefox_diff_page_statefor change detection.
firefox_get_accessibility_snapshot
Section titled “firefox_get_accessibility_snapshot”Get an accessibility tree snapshot. Returns the semantic structure of the page with roles, names, and states. Capped at 200 nodes by default.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
tabId | number | active tab | Target tab ID |
maxDepth | number | 5 | Maximum tree depth to traverse |
maxNodes | number | 200 | Maximum nodes to include (lower = faster) |
selector | string | body | CSS selector for root element |
timeout | number | 150000 | Request timeout in ms (5000-300000) |
Example
Section titled “Example”// Full page accessibility treeconst tree = await firefox_get_accessibility_snapshot({ tabId: 42 });
// Focused snapshot of a specific sectionconst nav = await firefox_get_accessibility_snapshot({ tabId: 42, selector: "nav.main-menu", maxDepth: 3});- Use
selectorto scope the snapshot to a specific region for faster results. - Lower
maxNodeswhen you only need a high-level overview of the page structure.
firefox_get_element
Section titled “firefox_get_element”Get detailed information about a specific element, including attributes, computed styles, visibility, and position.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | string | required | CSS selector for the element |
tabId | number | active tab | Target tab ID |
timeout | number | 150000 | Request timeout in ms (5000-300000) |
Example
Section titled “Example”const info = await firefox_get_element({ selector: "#submit-btn", tabId: 42});// Returns: attributes, computed styles, bounding rect, visibility state- Useful for debugging why a click or type command isn’t working (e.g., element is hidden or off-screen).
- Check the bounding rect to verify the element is within the viewport.
firefox_diff_page_state
Section titled “firefox_diff_page_state”Compare two getPageState snapshots to see what changed. Reports added, removed, and changed headings, links, buttons, and inputs. Useful for verifying that actions had the expected effect.
Parameters
Section titled “Parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
before | object | required | First getPageState snapshot |
after | object | required | Second getPageState snapshot |
timeout | number | 150000 | Request timeout in ms (5000-300000) |
Example
Section titled “Example”// Capture state before an actionconst before = await firefox_get_page_state({ tabId: 42 });
// Perform an actionawait firefox_click({ selector: "button.load-more", tabId: 42 });await firefox_wait_for({ selector: ".new-items", tabId: 42 });
// Capture state afterconst after = await firefox_get_page_state({ tabId: 42 });
// Diff the two snapshotsconst diff = await firefox_diff_page_state({ before, after });// Returns: { added: {...}, removed: {...}, changed: {...} }- Combine with
firefox_wait_forbetween snapshots to ensure the page has settled. - Useful for regression testing: capture a baseline, perform actions, and verify expected changes.