Skip to content

Commit

Permalink
[wdspec] Add test for NoSuchElement error with input.ElementOrigin
Browse files Browse the repository at this point in the history
Depends on D178185

Differential Revision: https://phabricator.services.mozilla.com/D178186

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1832028
gecko-commit: b0a6c81cf587e7e344eb16632f32df23b2e2456a
gecko-reviewers: webdriver-reviewers, jgraham
  • Loading branch information
juliandescottes authored and pull[bot] committed Aug 2, 2023
1 parent 34f51e5 commit 1180076
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/webdriver/webdriver/bidi/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class MoveTargetOutOfBoundsException(BidiException):
error_code = "move target out of bounds"


class NoSuchElementException(BidiException):
error_code = "no such element"


class NoSuchFrameException(BidiException):
error_code = "no such frame"

Expand Down
47 changes: 47 additions & 0 deletions webdriver/tests/bidi/input/perform_actions/invalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
from webdriver.bidi.error import (
InvalidArgumentException,
MoveTargetOutOfBoundsException,
NoSuchElementException,
NoSuchFrameException,
NoSuchNodeException,
)
from webdriver.bidi.modules.script import ContextTarget


pytestmark = pytest.mark.asyncio
Expand Down Expand Up @@ -160,6 +162,51 @@ async def test_params_actions_origin_invalid_value_serialized_element(
actions=actions, context=top_context["context"]
)

@pytest.mark.parametrize(
"expression",
[
"document.querySelector('input#button').attributes[0]",
"document.querySelector('#with-text-node').childNodes[0]",
"""document.createProcessingInstruction("xml-stylesheet", "href='foo.css'")""",
"document.querySelector('#with-comment').childNodes[0]",
"document",
"document.doctype",
"document.createDocumentFragment()",
"document.querySelector('#custom-element').shadowRoot",
],
ids=[
"attribute",
"text node",
"processing instruction",
"comment",
"document",
"doctype",
"document fragment",
"shadow root",
]
)
async def test_params_actions_origin_no_such_element(
bidi_session, top_context, get_test_page, expression
):
await bidi_session.browsing_context.navigate(
context=top_context["context"],
url=get_test_page(),
wait="complete",
)

node = await bidi_session.script.evaluate(
expression=expression,
target=ContextTarget(top_context["context"]),
await_promise=False,
)

actions = Actions()
actions.add_pointer().pointer_move(x=0, y=0, origin=get_element_origin(node))
with pytest.raises(NoSuchElementException):
await bidi_session.input.perform_actions(
actions=actions, context=top_context["context"]
)


async def test_params_actions_origin_no_such_node(bidi_session, top_context):
actions = Actions()
Expand Down

0 comments on commit 1180076

Please sign in to comment.