fix: forward boxes option in aria snapshots - #3356
Open
Mihail Galay (GalayM) wants to merge 4 commits into
Open
Mihail Galay (GalayM) wants to merge 4 commits into
Mihail Galay (GalayM) wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The fix is small and targeted (forwards the missing option) with solid regression tests, with only minor test-assertion refinements suggested.
Pull request overview
This PR fixes a bug where Boxes = true was ignored by Page.AriaSnapshotAsync() and Locator.AriaSnapshotAsync() by forwarding the option to the driver, and adds regression coverage to ensure bounding boxes appear when requested.
Changes:
- Forward
options.Boxesasboxesin theariaSnapshotdriver request for both Page and Locator snapshots. - Add new tests covering
Boxesbehavior for bothPageandLocatorinDefaultandAimodes.
File summaries
| File | Description |
|---|---|
| src/Playwright/Core/Page.cs | Forwards Boxes option to the ariaSnapshot request payload. |
| src/Playwright/Core/Locator.cs | Forwards Boxes option to the ariaSnapshot request payload for locators. |
| src/Playwright.Tests/PageAriaSnapshotTests.cs | Adds regression tests ensuring bounding boxes appear only when Boxes = true for both APIs and modes. |
Review details
Suppressed comments (1)
src/Playwright.Tests/PageAriaSnapshotTests.cs:59
- The final assertion repeats the earlier
Boxes = falsecheck, so it doesn’t verify the behavior whenBoxesis omitted after aBoxes = truecall. Consider changing this assertion to callAriaSnapshotAsyncwithoutBoxesto ensure omission still produces a snapshot without boxes (and that the option isn’t sticky).
Assert.AreEqual(snapshot, await locator.AriaSnapshotAsync(new() { Mode = mode, Boxes = false }));
var snapshotWithBoxes = await locator.AriaSnapshotAsync(new() { Mode = mode, Boxes = true });
StringAssert.Contains("[box=20,30,100,40]", snapshotWithBoxes);
Assert.AreEqual(snapshot, await locator.AriaSnapshotAsync(new() { Mode = mode, Boxes = false }));
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| var snapshotWithBoxes = await Page.AriaSnapshotAsync(new() { Mode = mode, Boxes = true }); | ||
| StringAssert.Contains("[box=20,30,100,40]", snapshotWithBoxes); | ||
| Assert.AreEqual(snapshot, await Page.AriaSnapshotAsync(new() { Mode = mode, Boxes = false })); |
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3355.
Boxes = trueis currently ignored by bothPage.AriaSnapshotAsync()andLocator.AriaSnapshotAsync(). Forward the option to the driver so snapshots include the documented bounding boxes.The tests cover both methods in
DefaultandAimodes, check exact geometry, and verify that omitted orfalseoptions leave boxes out, including omission after a call withBoxes = true.Also move
ResolveNpmExecutableabove the instance methods to fix the existing SA1204 failure blocking the code-style check. Its implementation is unchanged.Tested on Windows / .NET 8:
PageAriaSnapshotTestspass in Chromium, Firefox, and WebKit after the fix.dotnet build ./src --no-restoreanddotnet format ./src/ --verify-no-changes --no-restorepass.