Repository navigation
fix(browser): avoid strict mode violation in failure screenshot with nested <body> (fix #11434)
#11465
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Description
Resolves #11434
Bug: The failure screenshot used
locator('body'), which Playwright resolves across open shadow roots. If a page contains a<body>element inside a shadow root, the locator matches 2 elements and strict mode throws an error, so the screenshot is lost.Fix: I updated the locator string from
locator('body')tolocator('body').first()and then chained a.first()call before triggering the.screenshot().This prevents Playwright's strict mode check from failing when it pierces the shadow DOM and finds multiple
<body>elements, so the failure screenshot is captured as expected.Test: Added a regression test that renders a shadow root containing a
<body>element, triggers the failure screenshot path, and asserts the screenshot is taken without a strict mode violation. It fails without the fix.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.AI Usage
Claude was used to dig deeper into the problem. The bug was reproduced and reviewed by me.
PR opened by @feastyr69
Original implementation from #11442 by @feastyr69
All reactions