Skip to content

Commit 786a0f2

Browse files
committed
Fix accessibility command for Playwright 1.57+
Playwright 1.57.0 removed `page.accessibility.snapshot()` after 3 years of deprecation. This updates the accessibility command to use the new `locator.aria_snapshot()` API instead. Note: The output format has changed due to the new API returning a different accessibility tree structure (using semantic landmark roles like banner, main, contentinfo, navigation).
1 parent 8435690 commit 786a0f2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

shot_scraper/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,10 @@ def accessibility(
702702
skip_or_fail(response, skip, fail)
703703
if javascript:
704704
_evaluate_js(page, javascript)
705-
snapshot = page.accessibility.snapshot()
705+
snapshot = page.locator("body").aria_snapshot()
706706
browser_obj.close()
707-
output.write(json.dumps(snapshot, indent=4))
707+
# aria_snapshot() returns YAML, parse it for JSON output
708+
output.write(json.dumps(yaml.safe_load(snapshot), indent=4))
708709
output.write("\n")
709710

710711

0 commit comments

Comments
 (0)