fix(chv): 快照改走 page.aria_snapshot()
Playwright 1.64.1 已移除 page.accessibility,真实快照一路报 AttributeError(P2 假实现用的旧 API,单测一直没抓到;2026-11-08 构建 #8 驱动 live 抓到)。新版 aria_snapshot() 返回字符串, 超 64KB 截断;旧版 accessibility.snapshot()(dict)只作回落。 驱动的 a11y 断言接受 str 或 dict。
This commit is contained in:
1 parent
7361b0654f
commit
0bfb00ab1b
3 files changed
+72
-6
No files matched your search
@@ -554,7 +554,8 @@ class BrowserTest(unittest.TestCase):
|
||||
self.assertTrue(resp["ok"])
|
||||
self.assertEqual(resp["title"], "Example Domain")
|
||||
self.assertEqual(resp["url"], "https://example.com/")
|
||||
self.assertEqual(resp["a11y"]["role"], "WebArea")
|
||||
self.assertIsInstance(resp["a11y"], str)
|
||||
self.assertIn("Example Domain", resp["a11y"])
|
||||
snap = agent.snapshot()
|
||||
self.assertTrue(snap["ok"])
|
||||
shot = agent.screenshot()
|
||||
@@ -590,6 +591,11 @@ class FakePage:
|
||||
return {"role": "WebArea", "name": "Example Domain",
|
||||
"children": [{"role": "heading", "name": "Example"}]}
|
||||
|
||||
def aria_snapshot(self):
|
||||
# 当前 Playwright(1.64.1):快照是字符串,不是 dict 树。
|
||||
return ("- heading \"Example Domain\" [level=1]\n"
|
||||
"- paragraph \"Example\"")
|
||||
|
||||
def screenshot(self, path=None, type=None, quality=None):
|
||||
data = b"\xff\xd8\xff\xe0FAKEJPEG"
|
||||
if path:
|
||||
|
||||
Reference in new issue
Block a user