Skip to content

Commit 2402aad

Browse files
authored
docs(api): elaborate on fill vs type (#1608)
1 parent dd4fe90 commit 2402aad

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

docs/api.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,9 +1195,9 @@ const fs = require('fs');
11951195
- returns: <[Promise]> Promise which resolves when the element matching `selector` is successfully filled. The promise will be rejected if there is no element matching `selector`.
11961196

11971197
This method focuses the element and triggers an `input` event after filling.
1198-
If there's no text `<input>`, `<textarea>` or `[contenteditable]` element matching `selector`, the method throws an error.
1198+
If there's no text `<input>`, `<textarea>` or `[contenteditable]` element matching `selector`, the method throws an error. Note that you can pass an empty string to clear the input field.
11991199

1200-
> **NOTE** Pass empty string as a value to clear the input field.
1200+
To send fine-grained keyboard events, use [`page.type`](#pagetypeselector-text-options).
12011201

12021202
Shortcut for [page.mainFrame().fill()](#framefillselector-value-options)
12031203

@@ -1585,7 +1585,7 @@ Shortcut for [page.mainFrame().title()](#frametitle).
15851585
- `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
15861586
- returns: <[Promise]>
15871587

1588-
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
1588+
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send fine-grained keyboard events. To fill values in form fields, use [`page.fill`](#pagefillselector-value-options).
15891589

15901590
To press a special key, like `Control` or `ArrowDown`, use [`keyboard.press`](#keyboardpresskey-options).
15911591

@@ -2116,6 +2116,8 @@ await resultHandle.dispose();
21162116
This method focuses the element and triggers an `input` event after filling.
21172117
If there's no text `<input>`, `<textarea>` or `[contenteditable]` element matching `selector`, the method throws an error.
21182118

2119+
To send fine-grained keyboard events, use [`frame.type`](#frametypeselector-text-options).
2120+
21192121
#### frame.focus(selector[, options])
21202122
- `selector` <[string]> A selector of an element to focus. If there are multiple elements satisfying the selector, the first will be focused.
21212123
- `options` <[Object]>
@@ -2280,7 +2282,7 @@ frame.selectOption('select#colors', { value: 'blue' }, { index: 2 }, 'red');
22802282
- `timeout` <[number]> Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by using the [browserContext.setDefaultTimeout(timeout)](#browsercontextsetdefaulttimeouttimeout) or [page.setDefaultTimeout(timeout)](#pagesetdefaulttimeouttimeout) methods.
22812283
- returns: <[Promise]>
22822284

2283-
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
2285+
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to send fine-grained keyboard events. To fill values in form fields, use [`frame.fill`](#framefillselector-value-options).
22842286

22852287
To press a special key, like `Control` or `ArrowDown`, use [`keyboard.press`](#keyboardpresskey-options).
22862288

0 commit comments

Comments
 (0)