@@ -1388,6 +1388,50 @@ public PressOptions setTimeout(double timeout) {
13881388 return this ;
13891389 }
13901390 }
1391+ class PressSequentiallyOptions {
1392+ /**
1393+ * Time to wait between key presses in milliseconds. Defaults to 0.
1394+ */
1395+ public Double delay ;
1396+ /**
1397+ * Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
1398+ * opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
1399+ * inaccessible pages. Defaults to {@code false}.
1400+ */
1401+ public Boolean noWaitAfter ;
1402+ /**
1403+ * Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
1404+ * value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
1405+ * Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
1406+ */
1407+ public Double timeout ;
1408+
1409+ /**
1410+ * Time to wait between key presses in milliseconds. Defaults to 0.
1411+ */
1412+ public PressSequentiallyOptions setDelay (double delay ) {
1413+ this .delay = delay ;
1414+ return this ;
1415+ }
1416+ /**
1417+ * Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
1418+ * opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
1419+ * inaccessible pages. Defaults to {@code false}.
1420+ */
1421+ public PressSequentiallyOptions setNoWaitAfter (boolean noWaitAfter ) {
1422+ this .noWaitAfter = noWaitAfter ;
1423+ return this ;
1424+ }
1425+ /**
1426+ * Maximum time in milliseconds. Defaults to {@code 30000} (30 seconds). Pass {@code 0} to disable timeout. The default
1427+ * value can be changed by using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link
1428+ * Page#setDefaultTimeout Page.setDefaultTimeout()} methods.
1429+ */
1430+ public PressSequentiallyOptions setTimeout (double timeout ) {
1431+ this .timeout = timeout ;
1432+ return this ;
1433+ }
1434+ }
13911435 class ScreenshotOptions {
13921436 /**
13931437 * When set to {@code "disabled"}, stops CSS animations, CSS transitions and Web Animations. Animations get different
@@ -2832,7 +2876,7 @@ default JSHandle evaluateHandle(String expression) {
28322876 * href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
28332877 * instead.
28342878 *
2835- * <p> To send fine-grained keyboard events, use {@link Locator#type Locator.type ()}.
2879+ * <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially ()}.
28362880 *
28372881 * @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
28382882 * @since v1.14
@@ -2859,7 +2903,7 @@ default void fill(String value) {
28592903 * href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control">control</a>, the control will be filled
28602904 * instead.
28612905 *
2862- * <p> To send fine-grained keyboard events, use {@link Locator#type Locator.type ()}.
2906+ * <p> To send fine-grained keyboard events, use {@link Locator#pressSequentially Locator.pressSequentially ()}.
28632907 *
28642908 * @param value Value to set for the {@code <input>}, {@code <textarea>} or {@code [contenteditable]} element.
28652909 * @since v1.14
@@ -3956,6 +4000,60 @@ default void press(String key) {
39564000 * @since v1.14
39574001 */
39584002 void press (String key , PressOptions options );
4003+ /**
4004+ * <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
4005+ * there is special keyboard handling on the page.
4006+ *
4007+ * <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
4008+ * character in the text.
4009+ *
4010+ * <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
4011+ *
4012+ * <p> **Usage**
4013+ * <pre>{@code
4014+ * locator.pressSequentially("Hello"); // Types instantly
4015+ * locator.pressSequentially("World", new Locator.pressSequentiallyOptions().setDelay(100)); // Types slower, like a user
4016+ * }</pre>
4017+ *
4018+ * <p> An example of typing into a text field and then submitting the form:
4019+ * <pre>{@code
4020+ * Locator locator = page.getByLabel("Password");
4021+ * locator.pressSequentially("my password");
4022+ * locator.press("Enter");
4023+ * }</pre>
4024+ *
4025+ * @param text String of characters to sequentially press into a focused element.
4026+ * @since v1.38
4027+ */
4028+ default void pressSequentially (String text ) {
4029+ pressSequentially (text , null );
4030+ }
4031+ /**
4032+ * <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
4033+ * there is special keyboard handling on the page.
4034+ *
4035+ * <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
4036+ * character in the text.
4037+ *
4038+ * <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
4039+ *
4040+ * <p> **Usage**
4041+ * <pre>{@code
4042+ * locator.pressSequentially("Hello"); // Types instantly
4043+ * locator.pressSequentially("World", new Locator.pressSequentiallyOptions().setDelay(100)); // Types slower, like a user
4044+ * }</pre>
4045+ *
4046+ * <p> An example of typing into a text field and then submitting the form:
4047+ * <pre>{@code
4048+ * Locator locator = page.getByLabel("Password");
4049+ * locator.pressSequentially("my password");
4050+ * locator.press("Enter");
4051+ * }</pre>
4052+ *
4053+ * @param text String of characters to sequentially press into a focused element.
4054+ * @since v1.38
4055+ */
4056+ void pressSequentially (String text , PressSequentiallyOptions options );
39594057 /**
39604058 * Take a screenshot of the element matching the locator.
39614059 *
@@ -4865,26 +4963,9 @@ default String textContent() {
48654963 */
48664964 String textContent (TextContentOptions options );
48674965 /**
4868- * <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to type characters if there is
4869- * special keyboard handling on the page.
4870- *
4871- * <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
4872- * character in the text.
4873- *
4874- * <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
4875- *
4876- * <p> **Usage**
4877- * <pre>{@code
4878- * element.type("Hello"); // Types instantly
4879- * element.type("World", new Locator.TypeOptions().setDelay(100)); // Types slower, like a user
4880- * }</pre>
4881- *
4882- * <p> An example of typing into a text field and then submitting the form:
4883- * <pre>{@code
4884- * Locator element = page.getByLabel("Password");
4885- * element.type("my password");
4886- * element.press("Enter");
4887- * }</pre>
4966+ * @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
4967+ * there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
4968+ * Locator.pressSequentially()}.
48884969 *
48894970 * @param text A text to type into a focused element.
48904971 * @since v1.14
@@ -4893,26 +4974,9 @@ default void type(String text) {
48934974 type (text , null );
48944975 }
48954976 /**
4896- * <strong>NOTE:</strong> In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to type characters if there is
4897- * special keyboard handling on the page.
4898- *
4899- * <p> Focuses the element, and then sends a {@code keydown}, {@code keypress}/{@code input}, and {@code keyup} event for each
4900- * character in the text.
4901- *
4902- * <p> To press a special key, like {@code Control} or {@code ArrowDown}, use {@link Locator#press Locator.press()}.
4903- *
4904- * <p> **Usage**
4905- * <pre>{@code
4906- * element.type("Hello"); // Types instantly
4907- * element.type("World", new Locator.TypeOptions().setDelay(100)); // Types slower, like a user
4908- * }</pre>
4909- *
4910- * <p> An example of typing into a text field and then submitting the form:
4911- * <pre>{@code
4912- * Locator element = page.getByLabel("Password");
4913- * element.type("my password");
4914- * element.press("Enter");
4915- * }</pre>
4977+ * @deprecated In most cases, you should use {@link Locator#fill Locator.fill()} instead. You only need to press keys one by one if
4978+ * there is special keyboard handling on the page - in this case use {@link Locator#pressSequentially
4979+ * Locator.pressSequentially()}.
49164980 *
49174981 * @param text A text to type into a focused element.
49184982 * @since v1.14
0 commit comments