Skip to content

Commit

Permalink
[wdspec] add basic context locator tests (#50023)
Browse files Browse the repository at this point in the history
* [wdspec] add basic context locator tests

* Update webdriver/tests/bidi/browsing_context/locate_nodes/invalid.py

* Update webdriver/tests/bidi/browsing_context/locate_nodes/locator.py
  • Loading branch information
OrKoN authored Jan 13, 2025
1 parent f1f7dc9 commit 464fb19
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ async def test_params_locator_accessability_value_invalid_type(
("xpath", ""),
("innerText", ""),
("accessibility", {})
("context", {})
])
async def test_params_locator_value_invalid_value(bidi_session, inline, top_context, type, value):
await navigate_to_page(bidi_session, inline, top_context)
Expand Down
35 changes: 35 additions & 0 deletions webdriver/tests/bidi/browsing_context/locate_nodes/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,38 @@ async def test_locate_by_accessibility_attributes(
)

recursive_compare(expected, result["nodes"])


@pytest.mark.parametrize("domain", ["", "alt"], ids=["same_origin", "cross_origin"])
@pytest.mark.asyncio
async def test_locate_by_context(bidi_session, inline, top_context, domain):
iframe_url_1 = inline("<div id='in-iframe'>foo</div>", domain=domain)
page_url = inline(f"<iframe src='{iframe_url_1}'></iframe>")

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

contexts = await bidi_session.browsing_context.get_tree(root=top_context["context"])
iframe_context = contexts[0]["children"][0]

result = await bidi_session.browsing_context.locate_nodes(
context=top_context["context"],
locator={"type": "context", "value": { "context": iframe_context["context"] }}
)

expected = [
{
"type": "node",
"sharedId": any_string,
"value": {
"attributes": {"src": any_string},
"childNodeCount": 0,
"localName": "iframe",
"namespaceURI": "http://www.w3.org/1999/xhtml",
"nodeType": 1,
}
}
]

recursive_compare(expected, result["nodes"])

0 comments on commit 464fb19

Please sign in to comment.