Skip to content

Commit 14ebcfd

Browse files
authored
docs: update fill/selectOption docs to mention label retargeting (#6406)
1 parent fc9454e commit 14ebcfd

File tree

4 files changed

+77
-52
lines changed

4 files changed

+77
-52
lines changed

docs/src/api/class-elementhandle.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,11 @@ Optional argument to pass to [`param: expression`].
391391

392392
## async method: ElementHandle.fill
393393

394-
This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling.
395-
If the element is inside the `<label>` element that has associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be filled instead.
396-
If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
397-
Note that you can pass an empty string to clear the input field.
394+
This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.
395+
396+
If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
397+
398+
To send fine-grained keyboard events, use [`method: ElementHandle.type`].
398399

399400
### param: ElementHandle.fill.value
400401
- `value` <[string]>
@@ -591,12 +592,13 @@ Throws when `elementHandle` does not point to an element
591592
## async method: ElementHandle.selectOption
592593
- returns: <[Array]<[string]>>
593594

594-
Returns the array of option values that have been successfully selected.
595+
This method waits for [actionability](./actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
595596

596-
Triggers a `change` and `input` event once all the provided options have been selected. If element is not a `<select>`
597-
element, the method throws an error.
597+
If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
598+
599+
Returns the array of option values that have been successfully selected.
598600

599-
Will wait until all specified options are present in the `<select>` element.
601+
Triggers a `change` and `input` event once all the provided options have been selected.
600602

601603
```js
602604
// single selection matching the value

docs/src/api/class-frame.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,9 @@ Optional argument to pass to [`param: expression`].
609609

610610
## async method: Frame.fill
611611

612-
This method waits for an element matching [`param: selector`], waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling.
613-
If the element is inside the `<label>` element that has associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be filled instead.
614-
If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
615-
Note that you can pass an empty string to clear the input field.
612+
This method waits for an element matching [`param: selector`], waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.
613+
614+
If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
616615

617616
To send fine-grained keyboard events, use [`method: Frame.type`].
618617

@@ -920,12 +919,13 @@ returns empty array.
920919
## async method: Frame.selectOption
921920
- returns: <[Array]<[string]>>
922921

923-
Returns the array of option values that have been successfully selected.
922+
This method waits for an element matching [`param: selector`], waits for [actionability](./actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
924923

925-
Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
926-
matching [`param: selector`], the method throws an error.
924+
If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
925+
926+
Returns the array of option values that have been successfully selected.
927927

928-
Will wait until all specified options are present in the `<select>` element.
928+
Triggers a `change` and `input` event once all the provided options have been selected.
929929

930930
```js
931931
// single selection matching the value

docs/src/api/class-page.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,14 +1467,13 @@ Callback function which will be called in Playwright's context.
14671467

14681468
## async method: Page.fill
14691469

1470-
This method waits for an element matching [`param: selector`], waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling.
1471-
If the element is inside the `<label>` element that has associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be filled instead.
1472-
If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
1473-
Note that you can pass an empty string to clear the input field.
1470+
This method waits for an element matching [`param: selector`], waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input field.
1471+
1472+
If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
14741473

14751474
To send fine-grained keyboard events, use [`method: Page.type`].
14761475

1477-
Shortcut for main frame's [`method: Frame.fill`]
1476+
Shortcut for main frame's [`method: Frame.fill`].
14781477

14791478
### param: Page.fill.selector = %%-input-selector-%%
14801479

@@ -2255,12 +2254,13 @@ Defaults to `false`.
22552254
## async method: Page.selectOption
22562255
- returns: <[Array]<[string]>>
22572256
2258-
Returns the array of option values that have been successfully selected.
2257+
This method waits for an element matching [`param: selector`], waits for [actionability](./actionability.md) checks, waits until all specified options are present in the `<select>` element and selects these options.
22592258
2260-
Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
2261-
matching [`param: selector`], the method throws an error.
2259+
If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
2260+
2261+
Returns the array of option values that have been successfully selected.
22622262
2263-
Will wait until all specified options are present in the `<select>` element.
2263+
Triggers a `change` and `input` event once all the provided options have been selected.
22642264
22652265
```js
22662266
// single selection matching the value
@@ -2301,7 +2301,7 @@ page.select_option("select#colors", label="blue")
23012301
page.select_option("select#colors", value=["red", "green", "blue"])
23022302
```
23032303
2304-
Shortcut for main frame's [`method: Frame.selectOption`]
2304+
Shortcut for main frame's [`method: Frame.selectOption`].
23052305

23062306
### param: Page.selectOption.selector = %%-input-selector-%%
23072307

types/types.d.ts

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,16 +1724,19 @@ export interface Page {
17241724

17251725
/**
17261726
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the
1727-
* element, fills it and triggers an `input` event after filling. If the element is inside the `<label>` element that has
1728-
* associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be
1729-
* filled instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
1730-
* method throws an error. Note that you can pass an empty string to clear the input field.
1727+
* element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
1728+
* field.
1729+
*
1730+
* If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
1731+
* However, if the element is inside the `<label>` element that has an associated
1732+
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
1733+
* instead.
17311734
*
17321735
* To send fine-grained keyboard events, use
17331736
* [page.type(selector, text[, options])](https://playwright.dev/docs/api/class-page#pagetypeselector-text-options).
17341737
*
17351738
* Shortcut for main frame's
1736-
* [frame.fill(selector, value[, options])](https://playwright.dev/docs/api/class-frame#framefillselector-value-options)
1739+
* [frame.fill(selector, value[, options])](https://playwright.dev/docs/api/class-frame#framefillselector-value-options).
17371740
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
17381741
* @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
17391742
* @param options
@@ -2479,12 +2482,16 @@ export interface Page {
24792482
}): Promise<Buffer>;
24802483

24812484
/**
2482-
* Returns the array of option values that have been successfully selected.
2485+
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, waits until
2486+
* all specified options are present in the `<select>` element and selects these options.
24832487
*
2484-
* Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
2485-
* matching `selector`, the method throws an error.
2488+
* If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
2489+
* `<label>` element that has an associated
2490+
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
24862491
*
2487-
* Will wait until all specified options are present in the `<select>` element.
2492+
* Returns the array of option values that have been successfully selected.
2493+
*
2494+
* Triggers a `change` and `input` event once all the provided options have been selected.
24882495
*
24892496
* ```js
24902497
* // single selection matching the value
@@ -2499,7 +2506,7 @@ export interface Page {
24992506
* ```
25002507
*
25012508
* Shortcut for main frame's
2502-
* [frame.selectOption(selector, values[, options])](https://playwright.dev/docs/api/class-frame#frameselectoptionselector-values-options)
2509+
* [frame.selectOption(selector, values[, options])](https://playwright.dev/docs/api/class-frame#frameselectoptionselector-values-options).
25032510
* @param selector A selector to search for element. If there are multiple elements satisfying the selector, the first will be used. See [working with selectors](https://playwright.dev/docs/selectors) for more details.
25042511
* @param values Options to select. If the `<select>` has the `multiple` attribute, all matching options are selected, otherwise only the first option matching one of the passed options is selected. String values are equivalent to `{value:'string'}`. Option
25052512
* is considered matching if all specified properties match.
@@ -3889,10 +3896,13 @@ export interface Frame {
38893896

38903897
/**
38913898
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the
3892-
* element, fills it and triggers an `input` event after filling. If the element is inside the `<label>` element that has
3893-
* associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be
3894-
* filled instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
3895-
* method throws an error. Note that you can pass an empty string to clear the input field.
3899+
* element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
3900+
* field.
3901+
*
3902+
* If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
3903+
* However, if the element is inside the `<label>` element that has an associated
3904+
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
3905+
* instead.
38963906
*
38973907
* To send fine-grained keyboard events, use
38983908
* [frame.type(selector, text[, options])](https://playwright.dev/docs/api/class-frame#frametypeselector-text-options).
@@ -4257,12 +4267,16 @@ export interface Frame {
42574267
}): Promise<void>;
42584268

42594269
/**
4260-
* Returns the array of option values that have been successfully selected.
4270+
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, waits until
4271+
* all specified options are present in the `<select>` element and selects these options.
42614272
*
4262-
* Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
4263-
* matching `selector`, the method throws an error.
4273+
* If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
4274+
* `<label>` element that has an associated
4275+
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
42644276
*
4265-
* Will wait until all specified options are present in the `<select>` element.
4277+
* Returns the array of option values that have been successfully selected.
4278+
*
4279+
* Triggers a `change` and `input` event once all the provided options have been selected.
42664280
*
42674281
* ```js
42684282
* // single selection matching the value
@@ -6097,10 +6111,15 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
60976111

60986112
/**
60996113
* This method waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the element, fills it and triggers an `input`
6100-
* event after filling. If the element is inside the `<label>` element that has associated
6101-
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), that control will be filled
6102-
* instead. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method
6103-
* throws an error. Note that you can pass an empty string to clear the input field.
6114+
* event after filling. Note that you can pass an empty string to clear the input field.
6115+
*
6116+
* If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
6117+
* However, if the element is inside the `<label>` element that has an associated
6118+
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled
6119+
* instead.
6120+
*
6121+
* To send fine-grained keyboard events, use
6122+
* [elementHandle.type(text[, options])](https://playwright.dev/docs/api/class-elementhandle#elementhandletypetext-options).
61046123
* @param value Value to set for the `<input>`, `<textarea>` or `[contenteditable]` element.
61056124
* @param options
61066125
*/
@@ -6333,12 +6352,16 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
63336352
}): Promise<void>;
63346353

63356354
/**
6336-
* Returns the array of option values that have been successfully selected.
6355+
* This method waits for [actionability](https://playwright.dev/docs/actionability) checks, waits until all specified options are present in the
6356+
* `<select>` element and selects these options.
63376357
*
6338-
* Triggers a `change` and `input` event once all the provided options have been selected. If element is not a `<select>`
6339-
* element, the method throws an error.
6358+
* If the target element is not a `<select>` element, this method throws an error. However, if the element is inside the
6359+
* `<label>` element that has an associated
6360+
* [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be used instead.
6361+
*
6362+
* Returns the array of option values that have been successfully selected.
63406363
*
6341-
* Will wait until all specified options are present in the `<select>` element.
6364+
* Triggers a `change` and `input` event once all the provided options have been selected.
63426365
*
63436366
* ```js
63446367
* // single selection matching the value

0 commit comments

Comments
 (0)