diff --git a/playwright/accessibility.py b/playwright/accessibility.py
index ddc6dfc7b..44d0c4549 100644
--- a/playwright/accessibility.py
+++ b/playwright/accessibility.py
@@ -22,9 +22,9 @@ def __init__(self, channel: Channel) -> None:
self._channel = channel
async def snapshot(
- self, interestingOnly: bool = None, root: ElementHandle = None
+ self, interestingOnly: bool = True, root: ElementHandle = None
) -> Dict:
root = root._channel if root else None
return await self._channel.send(
- "snapshot", dict(root=root, interestingOnly=interestingOnly)
+ "accessibilitySnapshot", dict(root=root, interestingOnly=interestingOnly)
)
diff --git a/tests/test_accessibility.py b/tests/test_accessibility.py
new file mode 100644
index 000000000..c94846ddb
--- /dev/null
+++ b/tests/test_accessibility.py
@@ -0,0 +1,416 @@
+# Copyright (c) Microsoft Corporation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License")
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http:#www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import pytest
+
+
+async def test_accessibility_should_work(page, is_firefox, is_chromium):
+ await page.setContent(
+ """
+ Accessibility Test
+
+
+
Inputs
+
+
+
+
+
+
+
This is a description!
+
+ """
+ )
+ # autofocus happens after a delay in chrome these days
+ await page.waitForFunction("document.activeElement.hasAttribute('autofocus')")
+
+ if is_firefox:
+ golden = {
+ "role": "document",
+ "name": "Accessibility Test",
+ "children": [
+ {"role": "heading", "name": "Inputs", "level": 1},
+ {"role": "textbox", "name": "Empty input", "focused": True},
+ {"role": "textbox", "name": "readonly input", "readonly": True},
+ {"role": "textbox", "name": "disabled input", "disabled": True},
+ {"role": "textbox", "name": "Input with whitespace", "value": " "},
+ {"role": "textbox", "name": "", "value": "value only"},
+ {
+ "role": "textbox",
+ "name": "",
+ "value": "and a value",
+ }, # firefox doesn't use aria-placeholder for the name
+ {
+ "role": "textbox",
+ "name": "",
+ "value": "and a value",
+ "description": "This is a description!",
+ }, # and here
+ ],
+ }
+ elif is_chromium:
+ golden = {
+ "role": "WebArea",
+ "name": "Accessibility Test",
+ "children": [
+ {"role": "heading", "name": "Inputs", "level": 1},
+ {"role": "textbox", "name": "Empty input", "focused": True},
+ {"role": "textbox", "name": "readonly input", "readonly": True},
+ {"role": "textbox", "name": "disabled input", "disabled": True},
+ {"role": "textbox", "name": "Input with whitespace", "value": " "},
+ {"role": "textbox", "name": "", "value": "value only"},
+ {"role": "textbox", "name": "placeholder", "value": "and a value"},
+ {
+ "role": "textbox",
+ "name": "placeholder",
+ "value": "and a value",
+ "description": "This is a description!",
+ },
+ ],
+ }
+ else:
+ golden = {
+ "role": "WebArea",
+ "name": "Accessibility Test",
+ "children": [
+ {"role": "heading", "name": "Inputs", "level": 1},
+ {"role": "textbox", "name": "Empty input", "focused": True},
+ {"role": "textbox", "name": "readonly input", "readonly": True},
+ {"role": "textbox", "name": "disabled input", "disabled": True},
+ {"role": "textbox", "name": "Input with whitespace", "value": " "},
+ {"role": "textbox", "name": "", "value": "value only"},
+ {"role": "textbox", "name": "placeholder", "value": "and a value"},
+ {
+ "role": "textbox",
+ "name": "This is a description!",
+ "value": "and a value",
+ }, # webkit uses the description over placeholder for the name
+ ],
+ }
+ assert await page.accessibility.snapshot() == golden
+
+
+async def test_accessibility_should_work_with_regular_text(page, is_firefox):
+ await page.setContent("