docs: update deprecation messages for type() methods (#26912)

This commit is contained in:
Dmitry Gozman 2023-09-06 12:41:12 -07:00 committed by GitHub
parent 361038c950
commit abea8f4d1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 19 deletions

View file

@ -513,7 +513,7 @@ This method waits for [actionability](../actionability.md) checks, focuses the e
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. 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: Keyboard.type`]. To send fine-grained keyboard events, use [`method: Locator.pressSequentially`].
### param: ElementHandle.fill.value ### param: ElementHandle.fill.value
* since: v1.8 * since: v1.8
@ -977,7 +977,7 @@ Returns the `node.textContent`.
## async method: ElementHandle.type ## async method: ElementHandle.type
* since: v1.8 * since: v1.8
* deprecated: Use locator-based [`method: Locator.pressSequentially`] instead. Read more about [locators](../locators.md). * deprecated: In most cases, you should use [`method: Locator.fill`] instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [`method: Locator.pressSequentially`].
Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.

View file

@ -839,7 +839,7 @@ This method waits for an element matching [`param: selector`], waits for [action
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. 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`]. To send fine-grained keyboard events, use [`method: Locator.pressSequentially`].
### param: Frame.fill.selector = %%-input-selector-%% ### param: Frame.fill.selector = %%-input-selector-%%
* since: v1.8 * since: v1.8
@ -1733,7 +1733,7 @@ Returns the page title.
## async method: Frame.type ## async method: Frame.type
* since: v1.8 * since: v1.8
* deprecated: Use locator-based [`method: Locator.pressSequentially`] instead. Read more about [locators](../locators.md). * deprecated: In most cases, you should use [`method: Locator.fill`] instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [`method: Locator.pressSequentially`].
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `frame.type` can be used to 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 [`method: Frame.fill`]. send fine-grained keyboard events. To fill values in form fields, use [`method: Frame.fill`].

View file

@ -215,6 +215,10 @@ Sets input to the specified text value.
## async method: Keyboard.press ## async method: Keyboard.press
* since: v1.8 * since: v1.8
:::tip
In most cases, you should use [`method: Locator.press`] instead.
:::
[`param: key`] can specify the intended [`param: key`] can specify the intended
[keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
generate the text for. A superset of the [`param: key`] values can be found generate the text for. A superset of the [`param: key`] values can be found
@ -311,6 +315,10 @@ Time to wait between `keydown` and `keyup` in milliseconds. Defaults to 0.
## async method: Keyboard.type ## async method: Keyboard.type
* since: v1.8 * since: v1.8
:::caution
In most cases, you should use [`method: Locator.fill`] instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [`method: Locator.pressSequentially`].
:::
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`]. To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].

View file

@ -2096,7 +2096,7 @@ This method waits for an element matching [`param: selector`], waits for [action
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. 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`]. To send fine-grained keyboard events, use [`method: Locator.pressSequentially`].
### param: Page.fill.selector = %%-input-selector-%% ### param: Page.fill.selector = %%-input-selector-%%
* since: v1.8 * since: v1.8
@ -3772,7 +3772,7 @@ Returns the page's title.
## async method: Page.type ## async method: Page.type
* since: v1.8 * since: v1.8
* deprecated: Use locator-based [`method: Locator.pressSequentially`] instead. Read more about [locators](../locators.md). * deprecated: In most cases, you should use [`method: Locator.fill`] instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [`method: Locator.pressSequentially`].
Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. `page.type` can be used to send 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 [`method: Page.fill`]. fine-grained keyboard events. To fill values in form fields, use [`method: Page.fill`].

View file

@ -361,7 +361,7 @@ await page.GetByRole(AriaRole.Button).DispatchEventAsync("click");
## Type characters ## Type characters
:::tip :::caution
Most of the time, you should input text with [`method: Locator.fill`]. See the [Text input](#text-input) section above. You only need to type characters if there is special keyboard handling on the page. Most of the time, you should input text with [`method: Locator.fill`]. See the [Text input](#text-input) section above. You only need to type characters if there is special keyboard handling on the page.
::: :::

View file

@ -2355,7 +2355,7 @@ export interface Page {
* instead. * instead.
* *
* To send fine-grained keyboard events, use * To send fine-grained keyboard events, use
* [page.type(selector, text[, options])](https://playwright.dev/docs/api/class-page#page-type). * [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
* used. * used.
* @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element. * @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
@ -4111,9 +4111,10 @@ export interface Page {
* [keyboard.press(key[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-press). * [keyboard.press(key[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-press).
* *
* **Usage** * **Usage**
* @deprecated Use locator-based * @deprecated In most cases, you should use
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially) * [locator.fill(value[, options])](https://playwright.dev/docs/api/class-locator#locator-fill) instead. You only need
* instead. Read more about [locators](https://playwright.dev/docs/locators). * to press keys one by one if there is special keyboard handling on the page - in this case use
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
* used. * used.
* @param text A text to type into a focused element. * @param text A text to type into a focused element.
@ -5840,7 +5841,7 @@ export interface Frame {
* instead. * instead.
* *
* To send fine-grained keyboard events, use * To send fine-grained keyboard events, use
* [frame.type(selector, text[, options])](https://playwright.dev/docs/api/class-frame#frame-type). * [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
* used. * used.
* @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element. * @param value Value to fill for the `<input>`, `<textarea>` or `[contenteditable]` element.
@ -7123,9 +7124,10 @@ export interface Frame {
* [keyboard.press(key[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-press). * [keyboard.press(key[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-press).
* *
* **Usage** * **Usage**
* @deprecated Use locator-based * @deprecated In most cases, you should use
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially) * [locator.fill(value[, options])](https://playwright.dev/docs/api/class-locator#locator-fill) instead. You only need
* instead. Read more about [locators](https://playwright.dev/docs/locators). * to press keys one by one if there is special keyboard handling on the page - in this case use
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be * @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
* used. * used.
* @param text A text to type into a focused element. * @param text A text to type into a focused element.
@ -9664,7 +9666,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* instead. * instead.
* *
* To send fine-grained keyboard events, use * To send fine-grained keyboard events, use
* [keyboard.type(text[, options])](https://playwright.dev/docs/api/class-keyboard#keyboard-type). * [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).
* @param value Value to set for the `<input>`, `<textarea>` or `[contenteditable]` element. * @param value Value to set for the `<input>`, `<textarea>` or `[contenteditable]` element.
* @param options * @param options
*/ */
@ -10263,9 +10265,10 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* [elementHandle.press(key[, options])](https://playwright.dev/docs/api/class-elementhandle#element-handle-press). * [elementHandle.press(key[, options])](https://playwright.dev/docs/api/class-elementhandle#element-handle-press).
* *
* **Usage** * **Usage**
* @deprecated Use locator-based * @deprecated In most cases, you should use
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially) * [locator.fill(value[, options])](https://playwright.dev/docs/api/class-locator#locator-fill) instead. You only need
* instead. Read more about [locators](https://playwright.dev/docs/locators). * to press keys one by one if there is special keyboard handling on the page - in this case use
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).
* @param text A text to type into a focused element. * @param text A text to type into a focused element.
* @param options * @param options
*/ */
@ -17715,6 +17718,9 @@ export interface Keyboard {
insertText(text: string): Promise<void>; insertText(text: string): Promise<void>;
/** /**
* **NOTE** In most cases, you should use
* [locator.press(key[, options])](https://playwright.dev/docs/api/class-locator#locator-press) instead.
*
* `key` can specify the intended * `key` can specify the intended
* [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character * [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character
* to generate the text for. A superset of the `key` values can be found * to generate the text for. A superset of the `key` values can be found
@ -17761,6 +17767,11 @@ export interface Keyboard {
}): Promise<void>; }): Promise<void>;
/** /**
* **NOTE** In most cases, you should use
* [locator.fill(value[, options])](https://playwright.dev/docs/api/class-locator#locator-fill) instead. You only need
* to press keys one by one if there is special keyboard handling on the page - in this case use
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially).
*
* Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text. * Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
* *
* To press a special key, like `Control` or `ArrowDown`, use * To press a special key, like `Control` or `ArrowDown`, use