Skip to content

Name trace screenshots by their actual image format - #513

Merged
vishnuv688 merged 1 commit into
mainfrom
fix/505-screenshot-extension
Nov 2, 2026
Merged

vishnuv688 merged 1 commit into
mainfrom
fix/505-screenshot-extension

Conversation

@vishnuv688

Copy link
Copy Markdown
Member

What & why

Closes #505. Part of #494. Stacked on #509.

Every screenshot in a trace zip was stored as resources/<page>-<timestamp>.jpeg, though WebDriver screenshots and the polling recorder are PNG, so a viewer that takes the content type from the file name served a PNG as image/jpeg. The name now follows the image's own format: .png for PNG, .jpeg for JPEG.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Polish (an improvement to an existing feature)
  • Breaking change (existing behavior changes for users)
  • Documentation
  • Internal (build, CI, dependencies, tooling)

Packages touched

  • shared (types and contracts)
  • core (framework-agnostic capture/reporting)
  • elements (published element/snapshot API — @wdio/elements)
  • service (WebdriverIO adapter)
  • nightwatch-devtools (Nightwatch adapter)
  • selenium-devtools (Selenium adapter)
  • selenium-devtools-py (Selenium Python adapter)
  • backend (server)
  • app (UI)
  • script (page-injected runtime)
  • trace (Trace mode)

Capability matrix

  • packages/conformance/src/features.ts updated, and tables regenerated with pnpm docs:capabilities, if this adds or changes user-facing behaviour

Not needed: no per-adapter behaviour changes.

Notes for reviewers

What changed

  • imageExtension(base64) in shared names a base64 image's format, from the same magic-byte check as imageMime.
  • screenshotResourceName takes the screenshot, so the resource file, the filmstrip frame, the frame-snapshot override and the synthetic resource from Store each action screenshot once in the trace zip #508 all get the same name from one function. When two captures share a timestamp, the snapshot index and the resource writer pick the same one, so a name and its file cannot disagree on format.
  • The dense filmstrip had the same bug (every frame was <sha1>.jpeg, though polling mode and CDP with captureFormat: 'png' produce PNG); fixed the same way.

Compatibility

  • The reader opens whatever file name an event records, so zips written before this still open, in show-trace and in the hosted player. A test writes a zip, renames the PNG back to .jpeg in both the file and trace.trace as an old zip had it, and checks the reader still returns the image.
  • Python needs no change: its adapter sends snapshots to the backend, which writes the zip with trace, so Python traces get the right names automatically.

Testing

  • pnpm build, pnpm test (3302 passed) and pnpm lint are green.
  • New tests: the extension per format; resource writer and filmstrip agree, including on a shared timestamp; dense frames named by their bytes; in a fully written zip every filmstrip, override and synthetic resource name points at a stored file with a matching mimeType; old .jpeg-named PNG zips still read.

Not verified yet

  • A real trace from an example opened in the hosted player and in Playwright's viewer.
  • The docs site's wdio/TraceMode.md still says .jpeg; it is updated with the other docs-site changes once trace.webdriver.io is live.

Screenshots / recordings

Not applicable: no UI change.

🤖 Generated with Claude Code

Every screenshot resource was written as .jpeg, though WebDriver and the
polling recorder capture PNG, so a viewer that takes the content type from
the file name served a PNG as image/jpeg. The name now follows the bytes,
for the per-action screenshots and the dense filmstrip alike, and the
resource, filmstrip frame, frame-snapshot override and synthetic resource
all take it from one function. The reader opens whatever name an event
records, so zips written before this still open.

Closes #505

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vishnuv688
vishnuv688 force-pushed the ci/496-trace-size-budget branch from bd95ccb to 081e976 Compare October 30, 2026 10:12
@vishnuv688
vishnuv688 force-pushed the fix/505-screenshot-extension branch from 7a751ea to 730a86d Compare October 30, 2026 10:12
@vishnuv688
vishnuv688 changed the base branch from ci/496-trace-size-budget to main November 2, 2026 09:12
@vishnuv688
vishnuv688 merged commit 21a0012 into main Nov 2, 2026
9 checks passed
@vishnuv688
vishnuv688 deleted the fix/505-screenshot-extension branch November 2, 2026 09:21
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.

Trace: screenshots are PNG files saved with a .jpeg name

1 participant