Bug 1832028 - [wdspec] Add test for NoSuchElement error with input.ElementOrigin r=webdriver-reviewers,jgraham

Depends on D178185

Differential Revision: https://phabricator.services.mozilla.com/D178186
This commit is contained in:
Julian Descottes 2023-05-22 14:05:28 +00:00
Родитель 548bf8633f
Коммит 027251d764
2 изменённых файлов: 51 добавлений и 0 удалений

Просмотреть файл

@ -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"

Просмотреть файл

@ -4,9 +4,11 @@ from webdriver.bidi.modules.input import Actions, get_element_origin
from webdriver.bidi.error import (
InvalidArgumentException,
MoveTargetOutOfBoundsException,
NoSuchElementException,
NoSuchFrameException,
NoSuchNodeException,
)
from webdriver.bidi.modules.script import ContextTarget
pytestmark = pytest.mark.asyncio
@ -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()