Skip to content

Releases: percy/percy-playwright-python

v1.0.2

27 Mar 07:14
59cdb86

Choose a tag to compare

✨ New Features

Responsive Snapshot Capture

  • Capture DOM snapshots across multiple viewport widths in a single percy_snapshot() call
  • Viewport widths and heights are fetched dynamically from Percy CLI's GET /percy/widths-config endpoint
  • For each configured width: resizes viewport → waits for resize → optionally reloads → optionally sleeps → captures DOM
  • Original viewport is preserved and restored after all captures
  • Automatically disabled when percy.deferUploads: true
percy_snapshot(page, "Homepage", responsiveSnapshotCapture=True, widths=[375, 768, 1280])

Cookie Context Capture

  • Page cookies are collected via page.context().cookies() before each DOM serialization
  • Cookies (name, value, domain, path, expires, httpOnly, secure, sameSite) are attached in the snapshot payload, enabling the CLI to use them during asset discovery

Cross-Origin (CORS) Iframe Capture

  • Detects cross-origin iframes by comparing each frame's host against the main page host
  • For each cross-origin frame: injects Percy DOM script → serializes frame DOM independently → matches to main page via data-percy-element-id
  • Serialized CORS iframe data stored in domSnapshot.corsIframes for CLI-side stitching

🔧 Enhancements

  • Structured Logginglog() now POSTs {message, level} JSON to Percy CLI's /percy/log endpoint
  • HTTP Timeout — 600-second socket/connect timeout prevents hangs during CLI sync mode
  • CLI Config Caching — Healthcheck response stores CLI's config object for responsiveSnapshotCapture and deferUploads behavior

⚙️ Configuration

Environment Variable Description
RESPONSIVE_CAPTURE_SLEEP_TIME Delay (seconds) between each viewport-width capture
PERCY_RESPONSIVE_CAPTURE_RELOAD_PAGE Reload page between captures (true/false)
PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT Adjust capture height to account for browser chrome

Or via CLI config:

snapshot:
  responsiveSnapshotCapture: true

💥 Breaking Changes

Caution

DOM Snapshot Structure Change — The DOM snapshot format has changed from a plain string to a structured object:

{ "html": "...", "cookies": [...], "corsIframes": [...] }

Any downstream tooling or integrations that parse the DOM snapshot as a raw HTML string will break. Update consumers to read from the html key of the snapshot object.

Caution

CORS Iframe Support Requires CLI Update — Projects using cross-origin iframes must update Percy CLI. Older CLI versions do not process the domSnapshot.corsIframes field, causing CORS iframe content to be silently dropped from snapshots.

Caution

Responsive Capture + Defer Uploads Incompatibility — Responsive snapshot capture is automatically disabled when percy.deferUploads: true is set. If you rely on deferred uploads, responsive capture will not function.


📋 Requirements

Important

Percy CLI v1.31.10 or higher is required. This is a hard dependency for both:

  • Responsive Snapshot Capture — uses the new GET /percy/widths-config endpoint introduced in CLI v1.31.10
  • CORS Iframe Capture — requires CLI-side handling of the domSnapshot.corsIframes field

Neither feature will function correctly on earlier CLI versions. Please upgrade before using this SDK version:

npm install -g @percy/cli@^1.31.10

🧪 Testing

  • Added 59 new test cases achieving 100% code coverage
  • Coverage enforcement enabled with fail_under = 100 threshold

What's Changed

New Contributors

Full Changelog: v1.0.1...v1.0.2

v1.0.2-beta.1

23 Mar 11:19
ff8464a

Choose a tag to compare

v1.0.2-beta.1 Pre-release
Pre-release

✨ New Features

Responsive Snapshot Capture

  • Added responsiveSnapshotCapture option to capture DOM across multiple viewport widths in a single percy_snapshot() call
  • Viewport widths and heights are fetched dynamically from the Percy CLI GET /percy/widths-config endpoint
  • For each configured width: resizes the viewport → waits for resize (via PercyDOM.waitForResize()) → optionally reloads → optionally sleeps → captures DOM
  • Original viewport is preserved and restored after all widths are captured
  • Each snapshot is tagged with its capture width for accurate comparison
  • Automatically disabled when percy.deferUploads: true

Cookie Capture

  • Before each DOM serialization, all page cookies are collected via page.context().cookies() (with graceful fallback on failure)
  • Cookies (name, value, domain, path, expires, httpOnly, secure, sameSite) are attached as cookies in the snapshot payload, enabling the CLI to use them during asset discovery

Cross-Origin (CORS) Iframe Capture

  • Detects cross-origin iframes by comparing each frame's host against the main page host
  • For each cross-origin frame: injects the Percy DOM script → serializes the frame DOM independently → matches it to the main page via data-percy-element-id
  • Serialized CORS iframe data is stored in domSnapshot.corsIframes for CLI-side stitching
  • Sequential frame processing to avoid Playwright thread-safety issues

🔧 Enhancements

Structured Logging

  • log() now POSTs {message, level} JSON to the Percy CLI /percy/log endpoint in addition to printing to stdout
  • Debug-level messages are suppressed from stdout unless PERCY_LOGLEVEL=debug is set

HTTP Timeout (Percy CLI Sync Feature)

  • request() now applies a 600-second socket/connect timeout to support Percy CLI's synchronous processing mode, preventing long snapshot POST operations from hanging indefinitely while the CLI processes and uploads snapshots synchronously

CLI Config Caching

  • The healthcheck response now stores the CLI's config object
  • Drives responsiveSnapshotCapture and deferUploads behavior without requiring a CLI restart

DOM Snapshot Structure Change

  • DOM snapshot structure changed from string to object: {"html": "...", "cookies": [...], "corsIframes": [...]}

Testing & Coverage

  • Added 59 new test cases achieving 100% code coverage
  • Coverage enforcement enabled with fail_under = 100 threshold
  • New test file tests/test_init.py for wrapper tests

⚙️ Configuration Options

New environment variables:

Variable Description
RESPONSIVE_CAPTURE_SLEEP_TIME Delay in seconds between each viewport-width capture
PERCY_RESPONSIVE_CAPTURE_RELOAD_PAGE Reload page between captures (true/false)
PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT Adjust capture height to account for browser chrome (outerHeight - innerHeight + minH)

Enable responsive capture via SDK option:

percy_snapshot(page, "Homepage", responsiveSnapshotCapture=True)

Or via CLI config:

snapshot:
  responsiveSnapshotCapture: true

📋 Requirements

⚠️ Percy CLI v1.31.10 or higher is required — this version is a hard dependency for both Responsive Snapshot Capture (uses the new GET /percy/widths-config endpoint) and CORS Iframe Capture (requires CLI-side handling of the domSnapshot.corsIframes field). Neither feature will function correctly on earlier CLI versions.

  • CLI must expose GET /percy/widths-config for responsive capture width resolution
  • CLI must process domSnapshot.corsIframes for cross-origin iframe DOM stitching

💥 Impact

  • Breaking: DOM snapshot structure changed from string to object format
  • Breaking: Projects using CORS iframes must update Percy CLI to v1.31.9-beta.5 or higher
  • Compatibility: Responsive capture is automatically disabled when deferUploads is enabled
  • Performance: 600-second HTTP timeout prevents silent hangs on large snapshot payloads during CLI sync mode

What's Changed

  • feat: add responsive snapshot capture, cookie capture, and cross-origin iframe support by @bhokaremoin in #124

New Contributors

Full Changelog: v1.0.1...v1.0.2-beta.1

v1.0.1

16 Apr 06:48
e58264d

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.0.0...v1.0.1

v1.0.1-beta.0

04 Apr 13:39
a6c06de

Choose a tag to compare

v1.0.1-beta.0 Pre-release
Pre-release

What's Changed

New Contributors

Full Changelog: v1.0.0...v1.0.1-beta0

v1.0.0

25 Jun 08:13
674e9bf

Choose a tag to compare

What's Changed

  • @Amit3200 Percy Support for Playwright on Python for both Web, Browserstack Automate.
  • docs url update by @prklm10 in #11
  • Release percy-playwright v1.0.0 by @Amit3200 in #12

New Contributors

Full Changelog: v1.0.0-beta.0...v1.0.0

v1.0.0-beta.0

17 Jun 13:36
b7abdf3

Choose a tag to compare

v1.0.0-beta.0 Pre-release
Pre-release

What's Changed

New Contributors

Full Changelog: https://github.com/percy/percy-playwright-python/commits/v1.0.0-beta.0