Repository navigation
Conversation
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 |
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 |
12dd905 to
2be4d5e
Compare
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>
2be4d5e to
dd834a4
Compare
…driverIO 9 again") @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>
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>
The service now requires WebdriverIO 10, so the workspace builds and tests against the newest 10.x release. 10.1.0 does not carry webdriverio#16131, #16150 or #16152 yet; the move to the release that does follows once it ships. @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>
@wdio/session's collectTop remembers that a BiDi session has no classic executeScript and goes straight to execute afterwards; getSnapshot tried the classic path first on every call and paid a failed round trip each time an agent loop asked for a snapshot. The docstring also no longer promises a selector on every ref: @wdio/snapshot attaches only selectors that resolve to their element under BiDi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…10.2 getSnapshot picks its renderer from the installed WebdriverIO. From 10.2 (prereleases included) it renders with @wdio/snapshot; below that it keeps the renderer from upstream/main, so WebdriverIO 9 and 10.0-10.1 output does not change. The result is one additive type: format 'legacy' | 'snapshot', text, elements on both paths, and refs on the snapshot path. viewport is accepted next to inViewportOnly. The serializer and SnapshotResult exports return. SnapshotError is local, and @wdio/snapshot is loaded only through a dynamic import, so importing @wdio/elements on WebdriverIO 9 never loads it. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
… version browser.getSnapshot() defaults to the viewport on both renderers and reports the renderer's format in its failure value. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@wdio/elements takes the webdriverio peer back to ^9.0.0 || ^10.0.0, and the service peers return to upstream/main. @wdio/snapshot is ^10.2.0-0, so prereleases satisfy it. The wdio-peer matrix is [9, 10] again. Both packages get a minor changeset, because the result only gains fields. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
The renderer is chosen at runtime from the installed webdriverio, so the README and the getSnapshot JSDoc now state the 10.2 gate, the result fields per renderer, the per-renderer viewport default, and the ref without a selector case, instead of claiming one renderer's output for every install. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As a regular dependency, @wdio/snapshot nested a second, v10 webdriverio under itself in every npm project on WebdriverIO 9 or 10.1, which the wdio-peer smoke rejects. The new renderer now runs only when WebdriverIO is 10.2 or later and the project installed @wdio/snapshot itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…keep 1.x types @wdio/cli pulls @wdio/snapshot transitively through @wdio/session at its own exact version, so a ^10.2.0-0 optional peer made npm install a second @wdio/snapshot and webdriverio on 10.1. The peer now accepts any 10.x and the renderer gate checks the resolved @wdio/snapshot version instead. Both renderers default to the viewport, a failed load reports legacy, the native window size is read safely, and the published declarations no longer reference @wdio/snapshot, an optional peer most installs lack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The alpha carries webdriverio#16131, #16150 and #16152; this commit is for verification only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dd834a4 to
3d4c594
Compare
Snapshot renderer picked at runtime, no WebdriverIO 10 requirementThe renderer is opt-in:
The peer range is Legacy path unchangedOn WebdriverIO 9.32.0 and 10.1.0, Verified against WebdriverIO 10.2.0-alphaWebdriverIO Gate on the alpha: Selectors (#16131): I checked 15 pages twice each: the local fixture site, static probe pages, webdriver.io, the-internet and GitHub. Out of 1640 selectors, none matched more than one element. All 356 positional CSS paths resolved to the right element, and no Android (#16150): UiAutomator2 on an emulator against native-demo-app, Home/Login/Forms/Swipe, 3 runs. Every one of the 39 selectors resolves to exactly one element. The resource id Regression check against Correction: the output is not byte-identical to the CLI
The renderer and selector logic are shared. What differs comes from what the CLI session recorded. |
|
@greptileai review |
- Omit refs with no resolved selector from `elements`; their candidates stay in `refs`. - Require `@wdio/snapshot` ^10.2.0-0 as the optional peer, matching the runtime gate. - Return `[No elements found]` with a warning when a native page-source read fails, as the legacy renderer does, instead of rejecting. - Warn when the renderer checks fail or resolve an `@wdio/snapshot` below 10.2; stay silent only when it is not installed. - Fall back to the BiDi transport after two consecutive classic failures rather than one, so a transient script error does not latch it for the browser's lifetime. - Trim multi-line comments to one line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What & why
@wdio/elements'getSnapshotand the devtools service'sbrowser.getSnapshot()can now render with@wdio/snapshot, the renderer behindwdio session snapshot --selectors. Agents that read the CLI and agents that call this function then see the same format. The renderer is chosen at runtime, so no WebdriverIO version is dropped:main.@wdio/snapshotis never loaded.@wdio/snapshot10.2 or later installed:@wdio/snapshot. It is an optional peer, so it is opt-in:npm i -D @wdio/snapshot.The result is additive:
{ format: 'legacy' | 'snapshot', text, elements, refs? }.elementsis filled on both paths,refsonly on the snapshot path.inViewportOnlykeeps working, andviewportis accepted as an alias. Both renderers default to the viewport. Every exportmainhas is still there, so existing code compiles unchanged. Both packages therefore ship as a minor. A major comes only when the legacy renderer is dropped.On the snapshot path, a classic
executeScriptthat fails once is not retried on that browser; later snapshots go straight toexecute, as@wdio/session'scollectTopdoes.Type of change
show-tracebin each adapter declares is now shipped)Packages touched
shared(types and contracts):deepCapStringexported for native-session detection.core(framework-agnostic capture/reporting): unchanged public API; the snapshot builder stays for the legacy renderer.elements(published element/snapshot API —@wdio/elements): runtime renderer choice,snapshotRenderer(), additive result, optional@wdio/snapshotpeer.service(WebdriverIO adapter):browser.getSnapshot()returns the additive result; peers unchanged frommain.nightwatch-devtools(Nightwatch adapter): ships itsshow-tracebin; WebdriverIO 10.1.0 runtime ranges.selenium-devtools(Selenium adapter): ships itsshow-tracebin; WebdriverIO 10.1.0 runtime ranges.selenium-devtools-py(Selenium Python adapter)backend(server): WebdriverIO 10.1.0 runtime range.app(UI)script(page-injected runtime)trace(Trace mode)conformance(not in the list): the fake browser answersGET /timeoutsthe way a real one does..github/scripts/wdio-peer-smokeasserts the legacy renderer on both legs.Notes for reviewers
Waiting on WebdriverIO 10.2.0. The fixes
@wdio/snapshotneeds are released only as10.2.0-alpha.100.sha-b38abd894(npmnext): webdriverio/webdriverio#16131, #16150 and #16152. The top commit pins the workspace to that alpha for verification and is dropped before merge. webdriverio/webdriverio#16344, which makeswebdriverioa peer of@wdio/snapshot, should land in the same release. Results on the alpha are in the comment below.Behavior to know about:
wdio session snapshot --selectorson pages where the CLI session holds state this function lacks. The CLI has a page recorder that gives refs to elements with only a click listener, appends aRequests failed:note, and numbers refs across its session.--legacy-peer-deps, because the peer ranges do not admit prereleases.@wdio/elements'getSnapshot(browser)directly inside a devtools-service run shows the collector's script call as an Actions row.browser.getSnapshot()stays hidden.WebdriverIO 10.1.0 and conformance. In 10.1.0, BiDi
browser.executereadsGET /timeoutsfirst (webdriverio#16031). The conformance fake answered withnull, so everyexecutefailed. It now answers with the WebDriver defaults. Real Chrome traces are the same on 10.0.2 and 10.1.0.Screenshots / recordings
n/a (no UI change)
🤖 Generated with Claude Code