Repository navigation
Conversation
The hand-rolled snapshot builder drifted from what the wdio CLI prints for the same page. Delegating to @wdio/snapshot makes getSnapshot() output match `wdio session snapshot`. @wdio/snapshot requires webdriverio 10, so the peer range narrows to ^10.0.0; the service's getSnapshot command follows the new options/result shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
/packages/**/*.mjs is gitignored, so bin/show-trace.mjs was never committed and every published adapter declared a bin it did not ship. Also ignore the snapshot files the wdio example spec writes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wdio/devtools-service consumes @wdio/elements 2, which renders through @wdio/snapshot, and that package pins webdriverio exactly to a v10 release. A 9.x peer range could therefore never resolve, so the service's peers (webdriverio, @wdio/types, @wdio/reporter, @wdio/logger, @wdio/protocols, @wdio/allure-reporter) narrow to ^10.0.0. - changeset: mark the service major and spell out the break (getSnapshot returns refs, viewport replaces inViewportOnly, Node >=22.19.0) - CI: the wdio-peer smoke job drops the 9 leg; it only exercises the service and @wdio/elements - smoke.ts: GetSnapshotResult and the viewport option - CLAUDE.md, elements README: stop claiming getSnapshot shares the trace capture's scripts or keeps the portable XPath default Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The page source is stamped on the root by action-snapshot.ts; the helper the comment named no longer exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wdio/snapshot pins webdriverio exactly, so an exact @wdio/snapshot pin nested a second webdriverio under every consumer whose ^10 resolved a newer minor. A caret range lets the consumer's install pick the @wdio/snapshot release that matches its webdriverio, leaving one copy; the peer smoke asserts exactly that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The elements snapshot shim and its serializer surface were removed, so the docs no longer describe them as live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nges The audit found two consumer-visible changes the changeset did not mention: mobile browser sessions move from Appium's page source to the page collector, and native getElements stops attaching _sourceXML. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
207aa27 to
7cd00ab
Compare
[Medium impact] The reviewed changes appear safe to merge, with no new blocking findings. Summary
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
Service["browser.getSnapshot(): viewport by default"] --> API["getSnapshot"]
Direct["Direct call: full page by default"] --> API
API --> Native{"Native app capabilities?"}
Native -->|Yes| XML["Read and parse page source"]
Native -->|No| Web["Collect page tree"]
XML --> Render["@wdio/snapshot: attach selectors and format"]
Web --> Render
Render --> Result["Return text and refs"]
Reviews (3) · Last reviewed commit: "chore(changeset): note the WebdriverIO 1..." · Reviewed by Greptile |
| const platformName = String( | ||
| caps.platformName ?? caps['appium:platformName'] ?? '' | ||
| ).toLowerCase() | ||
| return NATIVE_PLATFORMS.has(platformName) && !caps.browserName |
There was a problem hiding this comment.
nativePlatformName ignores capabilities inside vendor options. The repository already supports native cloud sessions whose platformName exists only inside bstack:options. Those sessions now fall through to collectWebTree, which tries to run page JavaScript against a native app. browser.getSnapshot() then returns [Snapshot unavailable] instead of the app tree.
Read nested capabilities before choosing the collector, and pass the resolved platform to the native parser.
Knowledge Base Used: Guard capture paths for native and mobile-browser sessions
There was a problem hiding this comment.
Confirmed, and fixed in 9fca30c. Base routed on WDIO's isAndroid/isIOS, which read vendor options, so this was a regression from the move to @wdio/snapshot. nativePlatformName now reads platformName and browserName through shared's deepCapString, the same one-level vendor-bag reader the adapters already use for device detection. The resolved platform is passed on to the native parser. The tests cover a bstack:options-only Android session, which now takes the native path, and a nested browserName: 'Safari' session, which takes the web path.
Device clouds state platformName (and browserName) only inside a vendor bag such as bstack:options. nativePlatformName read top-level keys only, so those native sessions fell through to the web collector and getSnapshot returned "[Snapshot unavailable]". The base got this from WDIO's isAndroid/isIOS, which read vendor options too. Reuse shared's one-level deepCapString (now exported) rather than a second reader, and cover it with unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
WebdriverIO 10.1.0's BiDi execute reads the session's script timeout
before every call (scriptTimeoutOf, `getTimeouts().then(({ script }) =>
script, ...)`). The fake answered every unlisted endpoint with null, so
that destructuring threw inside the fulfilment handler, which its own
rejection handler does not catch: every browser.execute rejected before
script.callFunction was sent. The service never drained the collector
with its forced anchor, and the bidi:true scenario reported every
document unanchored and every row replaying the wrong page.
W3C requires GET /timeouts to return the timeouts object, and real
Chrome does: the mocha login example traces identically on 10.0.2 and
10.1.0 (4 of 4 documents anchored, 13 actions). The gap was the fake's.
The fixed-reply endpoints move into one table so the route stays under
the function-size cap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wdio/snapshot pins webdriverio exactly, so adopting the release that carries webdriverio#16131 needs the workspace on 10.1.0. @wdio/protocols stays at 10.0.2; no 10.1.0 was published. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ReviewThe refactor is the right direction: one renderer, with byte-identical output to Must fix before merge1. 2. Commit 3. Should fix4. 5. Scope. The description says the branch "carries only the snapshot change", but it also carries the workspace move to 10.1.0, the Nits
I didn't run the unit tests locally. Apart from Generated by Claude Code |
What & why
@wdio/elements'getSnapshot, and so the devtools service'sbrowser.getSnapshot(), now render their output with@wdio/snapshot. Before, they kept a second renderer that had drifted from the WebdriverIO CLI's. The result is byte-identical towdio session snapshot --selectors, so agents reading the CLI and agents calling this function see one format.@wdio/snapshotpinswebdriverioexactly to a v10 release. That makes@wdio/elements2 and@wdio/devtools-serviceWebdriverIO-10-only, and both get a major changeset. The rest of the workspace's move to WDIO 10 already landed in #434. This PR is rebuilt on top of it and carries only the snapshot change.Type of change
show-tracebin each adapter declares is now shipped)Packages touched
core: the old web snapshot builder is removed, andserializeMobileSnapshotis kept for trace captureelements:getSnapshotdelegates to@wdio/snapshotservice:browser.getSnapshot()returns{ text, refs }, and its peers are narrowed to^10.0.0shared:xpathLocatorTagremoved (no consumer)conformance: the fake browser answersGET /timeoutslike a real onenightwatch-devtools,selenium-devtools,backend: theshow-tracebin file is added to the two adapters, and the WebdriverIO 10.1.0 runtime ranges are bumped (patch changeset). More than one adapter is touched because each package ships its own bin; there is no logic to share incore.Notes for reviewers
The branch was checked for regressions against
upstream/mainin a real runtime: 3 runs per tree for e2e and Android, 2 for snapshot fidelity, and 4 for the bench. The runtime phases measured the head before the unrelated assertion-fold commit was split out into its own PR. The bench measured the final code.Per-action trace capture and live streaming are unchanged in every adapter, apart from the direct-
getSnapshotActions row described below. Cucumber step keywords are intact.getSnapshotis 42–57% faster, with smaller output.Known limitations, all in
@wdio/snapshotand to be fixed there rather than worked around here, so the output stays identical to the CLI:role/<role>[name="…"]resolves to nothing under BiDi when the accessible name has leading whitespace or icon content. An unanchored positional CSS path can match two elements. Both are mostly addressed by fix(snapshot): skip role/ candidate on leading whitespace and anchor ambiguous css path webdriverio#16131 (open). Reading its diff, two refs whosearia/fallback also resolves to nothing will likely remain.testID) is emitted asid=<id>, and UiAutomator2 resolves that to nothing. Upstream issue: [🐛 Bug]: @wdio/snapshot emits package-less Androidid=selectors that resolve to nothing webdriverio#16149.Behavior changes reviewers might trip over:
getSnapshotfrom@wdio/elementsdefaults to the full page;browser.getSnapshot()defaults to the viewport.getElementslost_sourceXML. It no longer attachestree.attributes._sourceXML.getSnapshotis called directly. Calling@wdio/elements'getSnapshot(browser)directly inside a devtools-service run shows the collector'sexecuteScriptcall as an Actions row. Usebrowser.getSnapshot()under the service, which stays hidden. Routing the collector throughbrowser.executeinstead would change the transport and break parity with the CLI.The workspace also moves to WebdriverIO 10.1.0 here, with
@wdio/snapshot10.1.0, whose build is byte-identical to 10.0.2. The bump first brokepackages/conformance("follows every rule", "adapters agree" under BiDi). The cause was the suite's fake browser, not devtools. In 10.1.0, BiDibrowser.executereadsGET /timeoutsfirst (webdriverio#16031), and the fake answered that withnull, so everyexecutefailed and no document was anchored. The fake now answers a GET of/timeoutswith the WebDriver defaults. Real Chrome traces are the same on 10.0.2 and 10.1.0.Stays in draft until #16131 and the Android resource-id fix (webdriverio/webdriverio#16149) are released in
@wdio/snapshot.Screenshots / recordings
n/a (no UI change)
🤖 Generated with Claude Code