Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wdspec] add basic context locator tests #50023

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"])