Commit 5dad639
authored
[feat]: add
# why
- to expose a public API for the snapshotting functionality used by
stagehand internally
# what changed
- added a new `page.snapshot()` function, which returns a
`SnapshotResult` object containing:
- a stringified, hierarchical tree representation of the DOM (the same
one that is given to the LLM internally)
- an xpath map, which contains a mapping of xpaths for elements on the
page, keyed by IDs
- a URL map, which contains a mapping of all URLs inlcuded in the page,
keyed by IDs
# test plan
- we already have comprehensive testing for the internals of this
function (`captureHybridSnapshot()`), and this new function does not
have any additional branching logic. existing unit tests & evals should
suffice.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Exposes a public page.snapshot() API to capture a formatted DOM snapshot
with xpath and URL maps. Addresses STG-1082 by making the internal
snapshotter available to users.
- New Features
- Added page.snapshot(): returns SnapshotResult { formattedTree,
xpathMap, urlMap } using captureHybridSnapshot (pierces shadow DOM).
- Introduced StagehandSnapshotError for snapshot failures (keeps
original cause).
- Exported SnapshotResult type.
- Refactors
- StagehandError now accepts and stores an optional cause for better
error chaining.
<sup>Written for commit e89840f.
Summary will update on new commits.</sup>
<!-- End of auto-generated description by cubic. -->page.snapshot() (#1518)1 parent e56c6eb commit 5dad639
File tree
5 files changed
+54
-4
lines changed- .changeset
- packages/core
- lib/v3
- types/public
- understudy
- tests/public-api
5 files changed
+54
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
9 | 14 | | |
10 | 15 | | |
11 | 16 | | |
| |||
370 | 375 | | |
371 | 376 | | |
372 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
12 | 15 | | |
13 | | - | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| |||
1789 | 1795 | | |
1790 | 1796 | | |
1791 | 1797 | | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
1792 | 1813 | | |
1793 | 1814 | | |
1794 | 1815 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
0 commit comments