diff --git a/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/invalid.py b/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/invalid.py index 4eb449b2ee80..52aabca2670e 100644 --- a/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/invalid.py +++ b/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/invalid.py @@ -59,10 +59,23 @@ async def test_params_locator_value_invalid_type( ) +@pytest.mark.parametrize("value", [None, False, 42, {}, []]) +async def test_params_locator_accessability_value_invalid_type( + bidi_session, inline, top_context, value +): + await navigate_to_page(bidi_session, inline, top_context) + + with pytest.raises(error.InvalidArgumentException): + await bidi_session.browsing_context.locate_nodes( + context=top_context["context"], locator={"type": "accessability", "value": value} + ) + + @pytest.mark.parametrize("type,value", [ ("css", "a*b"), ("xpath", ""), - ("innerText", "") + ("innerText", ""), + ("accessibility", {}) ]) async def test_params_locator_value_invalid_value(bidi_session, inline, top_context, type, value): await navigate_to_page(bidi_session, inline, top_context) diff --git a/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/locator.py b/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/locator.py index e560fa9239db..66c512d792a4 100644 --- a/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/locator.py +++ b/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/locator.py @@ -6,11 +6,17 @@ from ... import any_string, recursive_compare @pytest.mark.parametrize("type,value", [ ("css", "div"), ("xpath", "//div"), - ("innerText", "foobarBARbaz") + ("innerText", "foobarBARbaz"), + ("accessibility", {"role": "banner"}), + ("accessibility", {"name": "foo"}), + ("accessibility", {"role": "banner", "name": "foo"}), ]) @pytest.mark.asyncio async def test_find_by_locator(bidi_session, inline, top_context, type, value): - url = inline("""
foobarBARbaz
foobarBARbaz
""") + url = inline(""" +
foobarBARbaz
+
foobarBARbaz
+ """) await bidi_session.browsing_context.navigate( context=top_context["context"], url=url, wait="complete" ) @@ -165,3 +171,69 @@ async def test_find_by_inner_text(bidi_session, inline, top_context, locator, ex ) recursive_compare(expected, result["nodes"]) + + +@pytest.mark.parametrize( + "html,locator_value,expected_node_local_name", + [ + ( + "
foo
bar
", + {"role": "article"}, + "article", + ), + ( + "", + {"role": "searchbox"}, + "input", + ), + ( + "", + {"name": "Ok"}, + "button", + ), + ( + "
ok
go
", + {"name": "ok go"}, + "button", + ), + ( + "", + {"name": "foo"}, + "button", + ), + ( + "
", + {"role": "banner", "name": "foo"}, + "div", + ), + ], +) +@pytest.mark.asyncio +async def test_locate_by_accessibility_attributes( + bidi_session, + inline, + top_context, + html, + locator_value, + expected_node_local_name, +): + await bidi_session.browsing_context.navigate( + context=top_context["context"], url=inline(html), wait="complete" + ) + + expected = [ + { + "type": "node", + "value": { + "attributes": {"data-class": "one"}, + "localName": expected_node_local_name, + }, + } + ] + + result = await bidi_session.browsing_context.locate_nodes( + context=top_context["context"], + locator={"type": "accessibility", "value": locator_value}, + ) + + recursive_compare(expected, result["nodes"]) diff --git a/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/max_node_count.py b/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/max_node_count.py index 4652026e96fa..9d9c05260bc0 100644 --- a/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/max_node_count.py +++ b/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/max_node_count.py @@ -43,6 +43,45 @@ from ... import any_string, recursive_compare }, }] ), + ("accessibility", {"role": "banner"}, 1, [ + { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"one"}, + "childNodeCount": 1, + "localName": "div", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + }, + }] + ), + ("accessibility", {"name": "bar"}, 1, [ + { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"one"}, + "childNodeCount": 1, + "localName": "div", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + }, + }] + ), + ("accessibility", {"role": "banner", "name": "bar"}, 1, [ + { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"one"}, + "childNodeCount": 1, + "localName": "div", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + }, + }] + ), ("css", "div", 10, [ { "type": "node", @@ -114,18 +153,96 @@ from ... import any_string, recursive_compare "nodeType": 1, }, }] - ) + ), + ("accessibility", {"role": "banner"}, 10, [ + { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"one"}, + "childNodeCount": 1, + "localName": "div", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + }, + }, { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"two"}, + "childNodeCount": 1, + "localName": "div", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + }, + }] + ), + ("accessibility", {"name": "bar"}, 10, [ + { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"one"}, + "childNodeCount": 1, + "localName": "div", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + }, + }, { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"two"}, + "childNodeCount": 1, + "localName": "div", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + }, + }] + ), + ("accessibility", {"role": "banner", "name": "bar"}, 10, [ + { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"one"}, + "childNodeCount": 1, + "localName": "div", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + }, + }, { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"two"}, + "childNodeCount": 1, + "localName": "div", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + }, + }] + ), ], ids=[ "css_single", "xpath_single", "inner_text_single", + "accessibility_role_single", + "accessibility_name_single", + "accessibility_role_name_single", "css_multiple", "xpath_multiple", - "inner_text_multiple" + "inner_text_multiple", + "accessibility_role_multiple", + "accessibility_name_multiple", + "accessibility_role_name_multiple", ]) @pytest.mark.asyncio async def test_find_by_locator_limit_return_count(bidi_session, inline, top_context, type, value, max_count, expected): - url = inline("""
foo
foo
""") + url = inline(""" +
foo
+
foo
+ """) await bidi_session.browsing_context.navigate( context=top_context["context"], url=url, wait="complete" ) diff --git a/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/start_nodes.py b/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/start_nodes.py index 707d83a337d8..f44a6d4857c0 100644 --- a/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/start_nodes.py +++ b/testing/web-platform/tests/webdriver/tests/bidi/browsing_context/locate_nodes/start_nodes.py @@ -92,13 +92,59 @@ from ... import any_string, recursive_compare "namespaceURI": "http://www.w3.org/1999/xhtml", "nodeType": 1, } - }]) + }]), + ("accessibility", {"role": "banner"}, [{ + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"one"}, + "childNodeCount": 1, + "localName": "p", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + } + }, + { + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"two"}, + "childNodeCount": 1, + "localName": "p", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + } + }]), + ("accessibility", {"name": "bar"}, [{ + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"one"}, + "childNodeCount": 1, + "localName": "p", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + } + } + ]), + ("accessibility", {"role": "banner", "name": "bar"}, [{ + "type": "node", + "sharedId": any_string, + "value": { + "attributes": {"data-class":"one"}, + "childNodeCount": 1, + "localName": "p", + "namespaceURI": "http://www.w3.org/1999/xhtml", + "nodeType": 1, + } + } + ]) ]) @pytest.mark.asyncio async def test_locate_with_context_nodes(bidi_session, inline, top_context, type, value, expected): url = inline("""
-

foo

-

foo

+

foo

+

foo

bar @@ -125,14 +171,23 @@ async def test_locate_with_context_nodes(bidi_session, inline, top_context, type @pytest.mark.parametrize("type,value", [ ("css", "p[data-class='one']"), ("xpath", ".//p[@data-class='one']"), - ("innerText", "foo") + ("innerText", "foo"), + ("accessibility", {"role": "banner"}), + ("accessibility", {"name": "bar"}), + ("accessibility", {"role": "banner", "name": "bar"}), ]) @pytest.mark.asyncio async def test_locate_with_multiple_context_nodes(bidi_session, inline, top_context, type, value): url = inline(""" -

foo

bar

-

foo

bar

- """) +
+

foo

+

bar

+
+
+

foo

+

bar

+
+ """) await bidi_session.browsing_context.navigate( context=top_context["context"], url=url, wait="complete" )