diff --git a/playwright/src/test/java/com/microsoft/playwright/TestElementHandlePress.java b/playwright/src/test/java/com/microsoft/playwright/TestElementHandlePress.java
new file mode 100644
index 00000000..905beb34
--- /dev/null
+++ b/playwright/src/test/java/com/microsoft/playwright/TestElementHandlePress.java
@@ -0,0 +1,53 @@
+package com.microsoft.playwright;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class TestElementHandlePress extends TestBase {
+
+ @Test
+ void shouldWork() {
+ page.setContent("");
+ page.press("input", "h");
+ assertEquals("h", page.evalOnSelector("input", "input => input.value"));
+ }
+
+ @Test
+ void shouldNotSelectExistingValue() {
+ page.setContent("");
+ page.press("input", "w");
+ assertEquals("whello", page.evalOnSelector("input", "input => input.value"));
+ }
+
+ @Test
+ void shouldResetSelectionWhenNotFocused() {
+ page.setContent("
text
");
+ page.evalOnSelector("input", "input => {\n" +
+ " input.selectionStart = 2;\n" +
+ " input.selectionEnd = 4;\n" +
+ " document.querySelector('div').focus();\n" +
+ " }");
+ page.press("input", "w");
+ assertEquals("whello", page.evalOnSelector("input", "input => input.value"));
+ }
+
+ @Test
+ void shouldNotModifySelectionWhenFocused() {
+ page.setContent("");
+ page.evalOnSelector("input", "input => {\n" +
+ " input.focus();\n" +
+ " input.selectionStart = 2;\n" +
+ " input.selectionEnd = 4;\n" +
+ " }");
+ page.press("input", "w");
+ assertEquals("hewo", page.evalOnSelector("input", "input => input.value"));
+ }
+
+ @Test
+ void shouldWorkWithNumberInput() {
+ page.setContent("");
+ page.press("input", "1");
+ assertEquals("12", page.evalOnSelector("input", "input => input.value"));
+ }
+}
diff --git a/playwright/src/test/java/com/microsoft/playwright/TestElementHandleType.java b/playwright/src/test/java/com/microsoft/playwright/TestElementHandleType.java
new file mode 100644
index 00000000..092a1f2c
--- /dev/null
+++ b/playwright/src/test/java/com/microsoft/playwright/TestElementHandleType.java
@@ -0,0 +1,53 @@
+package com.microsoft.playwright;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class TestElementHandleType extends TestBase {
+
+ @Test
+ void shouldWork() {
+ page.setContent("");
+ page.type("input", "hello");
+ assertEquals("hello", page.evalOnSelector("input", "input => input.value"));
+ }
+
+ @Test
+ void shouldNotSelectExistingValue() {
+ page.setContent("");
+ page.type("input", "world");
+ assertEquals("worldhello", page.evalOnSelector("input", "input => input.value"));
+ }
+
+ @Test
+ void shouldResetSelectionWhenNotFocus() {
+ page.setContent("text
");
+ page.evalOnSelector("input", "input => {\n" +
+ " input.selectionStart = 2;\n" +
+ " input.selectionEnd = 4;\n" +
+ " document.querySelector('div').focus();\n" +
+ " }");
+ page.type("input", "world");
+ assertEquals("worldhello", page.evalOnSelector("input", "input => input.value"));
+ }
+
+ @Test
+ void shouldNotModifySelectionWhenFocus() {
+ page.setContent("");
+ page.evalOnSelector("input", "input => {\n" +
+ " input.focus();\n" +
+ " input.selectionStart = 2;\n" +
+ " input.selectionEnd = 4;\n" +
+ " }");
+ page.type("input", "world");
+ assertEquals("heworldo", page.evalOnSelector("input", "input => input.value"));
+ }
+
+ @Test
+ void shouldWorkWithNumberInput() {
+ page.setContent("");
+ page.type("input", "13");
+ assertEquals("132", page.evalOnSelector("input", "input => input.value"));
+ }
+}