Skip to content

Conversation

@seanmcguire12
Copy link
Member

@seanmcguire12 seanmcguire12 commented Jan 21, 2026

why

New public method page.snapshot()

what changed

Add documentation for the new page.snapshot() method in the v3 reference docs:

  • Method signature and description
  • Example output showing the formatted accessibility tree
  • Usage example with formattedTree, xpathMap, and urlMap
  • SnapshotResult type definition with field descriptions
  • Code example in the tabs section

test plan


Summary by cubic

Documented the new page.snapshot() API in the v3 reference. Shows how to capture the accessibility tree and get XPath/URL mappings for debugging and automation.

  • New Features
    • Added method signature, return type, and PageSnapshotOptions (includeIframes, default true).
  • Added examples using formattedTree, xpathMap, and urlMap.
    • Defined SnapshotResult and PageSnapshotOptions; tabbed code sample shows iframe exclusion.

Written for commit 012e5ce. Summary will update on new commits. Review in cubic

why

what changed

test plan

@changeset-bot
Copy link

changeset-bot bot commented Jan 21, 2026

⚠️ No Changeset found

Latest commit: 012e5ce

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 21, 2026

Greptile Summary

Documented the new page.snapshot() method in the v3 reference documentation. This method captures a structured accessibility tree snapshot of the page, providing a formatted text representation along with XPath and URL mappings for each element.

The documentation includes:

  • Complete method signature and return type definition
  • Detailed explanation of the formatted output structure with encoded IDs, roles, and accessible names
  • Example output showing the hierarchical accessibility tree structure
  • Practical usage examples demonstrating how to access formattedTree, xpathMap, and urlMap
  • Type definition for SnapshotResult with field descriptions
  • Code example in the tabbed section showing real-world usage patterns

The documentation follows the existing patterns in the file and provides clear, actionable examples for developers.

Confidence Score: 5/5

  • This documentation PR is safe to merge with no issues found
  • The PR adds well-structured documentation for a new public method. The documentation accurately reflects the implementation (verified against page.ts:1799-1811 and SnapshotResult type definition), follows existing documentation patterns, uses correct TypeScript syntax with camelCase naming convention, and provides clear examples with appropriate formatting. All code examples are syntactically correct and consistent with the style guide.
  • No files require special attention

Important Files Changed

Filename Overview
packages/docs/v3/references/page.mdx Added comprehensive documentation for the new page.snapshot() method including method signature, return type, example output, usage examples, and type definitions

Sequence Diagram

sequenceDiagram
    participant User
    participant Stagehand
    participant Page
    participant captureHybridSnapshot
    participant DOM

    User->>Stagehand: new Stagehand()
    User->>Stagehand: await init()
    User->>Stagehand: stagehand.context.pages()[0]
    Stagehand-->>User: page
    User->>Page: await page.goto("https://example.com")
    Page->>DOM: Navigate to URL
    DOM-->>Page: Page loaded
    User->>Page: await page.snapshot()
    Page->>captureHybridSnapshot: captureHybridSnapshot(page, { pierceShadow: true })
    captureHybridSnapshot->>DOM: Extract accessibility tree
    DOM-->>captureHybridSnapshot: Accessibility tree data
    captureHybridSnapshot-->>Page: { combinedTree, combinedXpathMap, combinedUrlMap }
    Page-->>User: { formattedTree, xpathMap, urlMap }
    User->>User: console.log(formattedTree)
    User->>User: Use xpathMap["0-8"] to get XPath
    User->>User: Use urlMap["0-8"] to get URL
Loading

chromiebot and others added 3 commits January 23, 2026 16:26
# why
New public method `page.snapshot()`

# what changed
Add documentation for the new page.snapshot() method in the v3 reference
docs:
- Method signature and description
- Example output showing the formatted accessibility tree
- Usage example with formattedTree, xpathMap, and urlMap
- SnapshotResult type definition with field descriptions
- Code example in the tabs section

# test plan


<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Documented the new page.snapshot() API in the v3 reference. Shows how to
capture the accessibility tree and get XPath/URL mappings for debugging
and automation.

- **New Features**
  - Added method signature and return type.
- Included example output and usage with formattedTree, xpathMap, and
urlMap.
  - Defined SnapshotResult and added a tabbed code sample.

<sup>Written for commit 39e0d29.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->

Co-authored-by: Chromie Bot <chromie@browserbase.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Update snapshot() method documentation to include the new optional
PageSnapshotOptions parameter with includeIframes option.

Changes:
- Update method signature to show optional options parameter
- Add ParamField for includeIframes option (defaults to true)
- Add PageSnapshotOptions type definition in Types section
- Add example showing iframe exclusion in code examples

# why

# what changed

# test plan

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Update page.snapshot() docs to show the new optional
PageSnapshotOptions, including the includeIframes flag (default true) to
control iframe content.
Adds the options parameter in the signature, documents includeIframes,
defines PageSnapshotOptions in Types, and includes an example excluding
iframe content.

<sup>Written for commit 3bffc93.
Summary will update on new commits.</sup>

<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Chromie Bot <chromie@browserbase.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
@seanmcguire12 seanmcguire12 changed the title [docs]: add docs for page.snapshot() (#1579) [docs]: add docs for page.snapshot() Jan 24, 2026
@seanmcguire12 seanmcguire12 merged commit 5d1fe37 into main Jan 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants