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

Run native focussing steps on interaction commands. #9267

Merged
merged 1 commit into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 8 additions & 1 deletion webdriver/tests/interaction/element_clear.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import pytest

from tests.support.asserts import assert_error, assert_success
from tests.support.asserts import (
assert_element_has_focus,
assert_error,
assert_success,
)
from tests.support.inline import inline


Expand Down Expand Up @@ -108,6 +112,7 @@ def test_input(session, type, value, default):
assert "focus" in events
assert "change" in events
assert "blur" in events
assert_element_has_focus(session.execute_script("return document.body"))


@pytest.mark.parametrize("type",
Expand Down Expand Up @@ -262,6 +267,7 @@ def test_contenteditable(session):
assert_success(response)
assert element.property("innerHTML") == ""
assert get_events(session) == ["focus", "change", "blur"]
assert_element_has_focus(session.execute_script("return document.body"))



Expand All @@ -274,6 +280,7 @@ def test_designmode(session):
response = element_clear(session, element)
assert_success(response)
assert element.property("innerHTML") == "<br>"
assert_element_has_focus(session.execute_script("return document.body"))


def test_resettable_element_focus_when_empty(session):
Expand Down
11 changes: 11 additions & 0 deletions webdriver/tests/support/asserts.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,14 @@ def assert_same_element(session, a, b):
pass

raise AssertionError(message)


def assert_element_has_focus(target_element):
session = target_element.session

active_element = session.execute_script("return document.activeElement")
active_tag = active_element.property("localName")
target_tag = target_element.property("localName")

assert active_element == target_element, (
"Focussed element is <%s>, not <%s>" % (active_tag, target_tag))