diff --git a/webdriver/tests/element_send_keys/content_editable.py b/webdriver/tests/element_send_keys/content_editable.py
index 7f628f96a53a00..9db19d5b8a2da8 100644
--- a/webdriver/tests/element_send_keys/content_editable.py
+++ b/webdriver/tests/element_send_keys/content_editable.py
@@ -1,18 +1,30 @@
+from tests.support.asserts import assert_element_has_focus
+
+
def test_sets_insertion_point_to_end(session, inline):
session.url = inline('
Hello,
')
+ body = session.find.css("body", all=False)
+ assert_element_has_focus(body)
+
input = session.find.css("div", all=False)
input.send_keys(' world!')
- text = session.execute_script('return arguments[0].innerText', args=[input])
+ text = session.execute_script('return arguments[0].textContent', args=[input])
assert "Hello, world!" == text.strip()
+ assert_element_has_focus(input)
-# 12. Let current text length be the element's length.
-#
-# 13. Set the text insertion caret using set selection range using current
-# text length for both the start and end parameters.
def test_sets_insertion_point_to_after_last_text_node(session, inline):
session.url = inline('Hello ,
')
input = session.find.css("div", all=False)
input.send_keys(" world!")
- text = session.execute_script("return arguments[0].innerText", args=[input])
+ text = session.execute_script("return arguments[0].textContent", args=[input])
assert "Hello, world!" == text.strip()
+
+
+def test_no_move_caret_if_focused(session, inline):
+ session.url = inline("""Hello ,
+""")
+ input = session.find.css("div", all=False)
+ input.send_keys("world!")
+ text = session.execute_script("return arguments[0].textContent", args=[input])
+ assert "world!Hello," == text.strip()
diff --git a/webdriver/tests/element_send_keys/file_upload.py b/webdriver/tests/element_send_keys/file_upload.py
index ef792f4dd85555..f62a633c202d6f 100644
--- a/webdriver/tests/element_send_keys/file_upload.py
+++ b/webdriver/tests/element_send_keys/file_upload.py
@@ -1,6 +1,9 @@
import pytest
-from tests.support.asserts import assert_error, assert_files_uploaded, assert_success
+from tests.support.asserts import (assert_element_has_focus,
+ assert_error,
+ assert_files_uploaded,
+ assert_success)
from . import map_files_to_multiline_text
@@ -207,6 +210,38 @@ def test_display_none(session, create_files, inline):
assert_files_uploaded(session, element, files)
+@pytest.mark.capabilities({"strictFileInteractability": False})
+def test_not_focused(session, create_files, inline):
+ files = create_files(["foo"])
+
+ session.url = inline(" ")
+ body = session.find.css("body", all=False)
+ element = session.find.css("input", all=False)
+ assert_element_has_focus(body)
+
+ response = element_send_keys(session, element, str(files[0]))
+ assert_success(response)
+ assert_element_has_focus(body)
+
+ assert_files_uploaded(session, element, files)
+
+
+@pytest.mark.capabilities({"strictFileInteractability": True})
+def test_focused(session, create_files, inline):
+ files = create_files(["foo"])
+
+ session.url = inline(" ")
+ body = session.find.css("body", all=False)
+ element = session.find.css("input", all=False)
+ assert_element_has_focus(body)
+
+ response = element_send_keys(session, element, str(files[0]))
+ assert_success(response)
+ assert_element_has_focus(element)
+
+ assert_files_uploaded(session, element, files)
+
+
@pytest.mark.capabilities({"strictFileInteractability": True})
def test_strict_hidden(session, create_files, inline):
files = create_files(["foo"])
diff --git a/webdriver/tests/element_send_keys/form_controls.py b/webdriver/tests/element_send_keys/form_controls.py
index 0403dc92372eea..364d4c28fae780 100644
--- a/webdriver/tests/element_send_keys/form_controls.py
+++ b/webdriver/tests/element_send_keys/form_controls.py
@@ -31,10 +31,13 @@ def test_textarea(session, inline):
def test_input_append(session, inline):
session.url = inline(" ")
+ body = session.find.css("body", all=False)
+ assert_element_has_focus(body)
element = session.find.css("input", all=False)
assert element.property("value") == "a"
element_send_keys(session, element, "b")
+ assert_element_has_focus(element)
assert element.property("value") == "ab"
element_send_keys(session, element, "c")
@@ -43,11 +46,57 @@ def test_input_append(session, inline):
def test_textarea_append(session, inline):
session.url = inline("")
+ body = session.find.css("body", all=False)
+ assert_element_has_focus(body)
element = session.find.css("textarea", all=False)
assert element.property("value") == "a"
element_send_keys(session, element, "b")
+ assert_element_has_focus(element)
assert element.property("value") == "ab"
element_send_keys(session, element, "c")
assert element.property("value") == "abc"
+
+
+def test_input_insert_when_focused(session, inline):
+ session.url = inline("""
+""")
+ element = session.find.css("input", all=False)
+ assert element.property("value") == "a"
+
+ element_send_keys(session, element, "b")
+ assert element.property("value") == "ba"
+
+ element_send_keys(session, element, "c")
+ assert element.property("value") == "bca"
+
+
+def test_textarea_insert_when_focused(session, inline):
+ session.url = inline("""
+""")
+ element = session.find.css("textarea", all=False)
+ assert element.property("value") == "a"
+
+ element_send_keys(session, element, "b")
+ assert element.property("value") == "ba"
+
+ element_send_keys(session, element, "c")
+ assert element.property("value") == "bca"
+
+
+def test_date(session, inline):
+ session.url = inline(" ")
+ element = session.find.css("input", all=False)
+
+ element_send_keys(session, element, "2000-01-01")
+ assert element.property("value") == "2000-01-01"
+ assert_element_has_focus(element)
diff --git a/webdriver/tests/element_send_keys/scroll_into_view.py b/webdriver/tests/element_send_keys/scroll_into_view.py
index 205c4e30e1edfa..7ccaeaf8142011 100644
--- a/webdriver/tests/element_send_keys/scroll_into_view.py
+++ b/webdriver/tests/element_send_keys/scroll_into_view.py
@@ -30,42 +30,6 @@ def test_element_outside_of_scrollable_viewport(session, inline):
assert is_element_in_viewport(session, element)
-def test_option_select_container_outside_of_scrollable_viewport(session, inline):
- session.url = inline("""
-
- foo
- bar
-
- """)
- element = session.find.css("option#bar", all=False)
- select = session.find.css("select", all=False)
-
- response = element_send_keys(session, element, "bar")
- assert_success(response)
-
- assert is_element_in_viewport(session, select)
- assert is_element_in_viewport(session, element)
-
-
-def test_option_stays_outside_of_scrollable_viewport(session, inline):
- session.url = inline("""
-
- foo
- bar
-
- """)
- select = session.find.css("select", all=False)
- option_foo = session.find.css("option#foo", all=False)
- option_bar = session.find.css("option#bar", all=False)
-
- response = element_send_keys(session, option_bar, "bar")
- assert_success(response)
-
- assert is_element_in_viewport(session, select)
- assert is_element_in_viewport(session, option_foo)
- assert not is_element_in_viewport(session, option_bar)
-
-
def test_contenteditable_element_outside_of_scrollable_viewport(session, inline):
session.url = inline("
")
element = session.find.css("div", all=False)