Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update fill/selectOption docs to mention label retargeting #6406

Merged
merged 1 commit into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions docs/src/api/class-elementhandle.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,11 @@ Optional argument to pass to [`param: expression`].

## async method: ElementHandle.fill

This method waits for [actionability](./actionability.md) checks, focuses the element, fills it and triggers an `input` event after filling.
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.
If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
Note that you can pass an empty string to clear the input field.
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.

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.

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

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

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

Triggers a `change` and `input` event once all the provided options have been selected. If element is not a `<select>`
element, the method throws an error.
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.

Returns the array of option values that have been successfully selected.

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

```js
// single selection matching the value
Expand Down
16 changes: 8 additions & 8 deletions docs/src/api/class-frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,9 @@ Optional argument to pass to [`param: expression`].

## async method: Frame.fill

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.
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.
If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
Note that you can pass an empty string to clear the input field.
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.

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.

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

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

Returns the array of option values that have been successfully selected.
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.

Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
matching [`param: selector`], the method throws an error.
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.

Returns the array of option values that have been successfully selected.

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

```js
// single selection matching the value
Expand Down
20 changes: 10 additions & 10 deletions docs/src/api/class-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -1467,14 +1467,13 @@ Callback function which will be called in Playwright's context.

## async method: Page.fill

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.
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.
If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error.
Note that you can pass an empty string to clear the input field.
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.

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.

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

Shortcut for main frame's [`method: Frame.fill`]
Shortcut for main frame's [`method: Frame.fill`].

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

Expand Down Expand Up @@ -2255,12 +2254,13 @@ Defaults to `false`.
## async method: Page.selectOption
- returns: <[Array]<[string]>>

Returns the array of option values that have been successfully selected.
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.

Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
matching [`param: selector`], the method throws an error.
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.

Returns the array of option values that have been successfully selected.

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

```js
// single selection matching the value
Expand Down Expand Up @@ -2301,7 +2301,7 @@ page.select_option("select#colors", label="blue")
page.select_option("select#colors", value=["red", "green", "blue"])
```

Shortcut for main frame's [`method: Frame.selectOption`]
Shortcut for main frame's [`method: Frame.selectOption`].

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

Expand Down
75 changes: 49 additions & 26 deletions types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1724,16 +1724,19 @@ export interface Page {

/**
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the
* element, fills it and triggers an `input` event after filling. 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. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
* method throws an error. Note that you can pass an empty string to clear the input field.
* element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
* field.
*
* 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.
*
* To send fine-grained keyboard events, use
* [page.type(selector, text[, options])](https://playwright.dev/docs/api/class-page#pagetypeselector-text-options).
*
* Shortcut for main frame's
* [frame.fill(selector, value[, options])](https://playwright.dev/docs/api/class-frame#framefillselector-value-options)
* [frame.fill(selector, value[, options])](https://playwright.dev/docs/api/class-frame#framefillselector-value-options).
* @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.
* @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
* @param options
Expand Down Expand Up @@ -2479,12 +2482,16 @@ export interface Page {
}): Promise<Buffer>;

/**
* Returns the array of option values that have been successfully selected.
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, waits until
* all specified options are present in the `<select>` element and selects these options.
*
* Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
* matching `selector`, the method throws an error.
* 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.
*
* Will wait until all specified options are present in the `<select>` element.
* Returns the array of option values that have been successfully selected.
*
* Triggers a `change` and `input` event once all the provided options have been selected.
*
* ```js
* // single selection matching the value
Expand All @@ -2499,7 +2506,7 @@ export interface Page {
* ```
*
* Shortcut for main frame's
* [frame.selectOption(selector, values[, options])](https://playwright.dev/docs/api/class-frame#frameselectoptionselector-values-options)
* [frame.selectOption(selector, values[, options])](https://playwright.dev/docs/api/class-frame#frameselectoptionselector-values-options).
* @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.
* @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
* is considered matching if all specified properties match.
Expand Down Expand Up @@ -3889,10 +3896,13 @@ export interface Frame {

/**
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the
* element, fills it and triggers an `input` event after filling. 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. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this
* method throws an error. Note that you can pass an empty string to clear the input field.
* element, fills it and triggers an `input` event after filling. Note that you can pass an empty string to clear the input
* field.
*
* 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.
*
* To send fine-grained keyboard events, use
* [frame.type(selector, text[, options])](https://playwright.dev/docs/api/class-frame#frametypeselector-text-options).
Expand Down Expand Up @@ -4257,12 +4267,16 @@ export interface Frame {
}): Promise<void>;

/**
* Returns the array of option values that have been successfully selected.
* This method waits for an element matching `selector`, waits for [actionability](https://playwright.dev/docs/actionability) checks, waits until
* all specified options are present in the `<select>` element and selects these options.
*
* Triggers a `change` and `input` event once all the provided options have been selected. If there's no `<select>` element
* matching `selector`, the method throws an error.
* 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.
*
* Will wait until all specified options are present in the `<select>` element.
* Returns the array of option values that have been successfully selected.
*
* Triggers a `change` and `input` event once all the provided options have been selected.
*
* ```js
* // single selection matching the value
Expand Down Expand Up @@ -6097,10 +6111,15 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {

/**
* This method waits for [actionability](https://playwright.dev/docs/actionability) checks, focuses the element, fills it and triggers an `input`
* event after filling. 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. If the element to be filled is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method
* throws an error. Note that you can pass an empty string to clear the input field.
* event after filling. Note that you can pass an empty string to clear the input field.
*
* 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.
*
* To send fine-grained keyboard events, use
* [elementHandle.type(text[, options])](https://playwright.dev/docs/api/class-elementhandle#elementhandletypetext-options).
* @param value Value to set for the `<input>`, `<textarea>` or `[contenteditable]` element.
* @param options
*/
Expand Down Expand Up @@ -6333,12 +6352,16 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
}): Promise<void>;

/**
* Returns the array of option values that have been successfully selected.
* This method waits for [actionability](https://playwright.dev/docs/actionability) checks, waits until all specified options are present in the
* `<select>` element and selects these options.
*
* Triggers a `change` and `input` event once all the provided options have been selected. If element is not a `<select>`
* element, the method throws an error.
* 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.
*
* Returns the array of option values that have been successfully selected.
*
* Will wait until all specified options are present in the `<select>` element.
* Triggers a `change` and `input` event once all the provided options have been selected.
*
* ```js
* // single selection matching the value
Expand Down