docs: update deprecation messages for type() methods (#26912)
This commit is contained in:
parent
361038c950
commit
abea8f4d1c
|
|
@ -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.
|
||||
|
||||
To send fine-grained keyboard events, use [`method: Keyboard.type`].
|
||||
To send fine-grained keyboard events, use [`method: Locator.pressSequentially`].
|
||||
|
||||
### param: ElementHandle.fill.value
|
||||
* since: v1.8
|
||||
|
|
@ -977,7 +977,7 @@ Returns the `node.textContent`.
|
|||
|
||||
## async method: ElementHandle.type
|
||||
* 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.
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
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-%%
|
||||
* since: v1.8
|
||||
|
|
@ -1733,7 +1733,7 @@ Returns the page title.
|
|||
|
||||
## async method: Frame.type
|
||||
* 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
|
||||
send fine-grained keyboard events. To fill values in form fields, use [`method: Frame.fill`].
|
||||
|
|
|
|||
|
|
@ -215,6 +215,10 @@ Sets input to the specified text value.
|
|||
## async method: Keyboard.press
|
||||
* since: v1.8
|
||||
|
||||
:::tip
|
||||
In most cases, you should use [`method: Locator.press`] instead.
|
||||
:::
|
||||
|
||||
[`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
|
||||
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
|
||||
* 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.
|
||||
|
||||
To press a special key, like `Control` or `ArrowDown`, use [`method: Keyboard.press`].
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
||||
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-%%
|
||||
* since: v1.8
|
||||
|
|
@ -3772,7 +3772,7 @@ Returns the page's title.
|
|||
|
||||
## async method: Page.type
|
||||
* 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
|
||||
fine-grained keyboard events. To fill values in form fields, use [`method: Page.fill`].
|
||||
|
|
|
|||
|
|
@ -361,7 +361,7 @@ await page.GetByRole(AriaRole.Button).DispatchEventAsync("click");
|
|||
|
||||
## 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.
|
||||
:::
|
||||
|
||||
|
|
|
|||
35
packages/playwright-core/types/types.d.ts
vendored
35
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -2355,7 +2355,7 @@ export interface Page {
|
|||
* instead.
|
||||
*
|
||||
* 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
|
||||
* used.
|
||||
* @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).
|
||||
*
|
||||
* **Usage**
|
||||
* @deprecated Use locator-based
|
||||
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially)
|
||||
* instead. Read more about [locators](https://playwright.dev/docs/locators).
|
||||
* @deprecated 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).
|
||||
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
|
||||
* used.
|
||||
* @param text A text to type into a focused element.
|
||||
|
|
@ -5840,7 +5841,7 @@ export interface Frame {
|
|||
* instead.
|
||||
*
|
||||
* 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
|
||||
* used.
|
||||
* @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).
|
||||
*
|
||||
* **Usage**
|
||||
* @deprecated Use locator-based
|
||||
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially)
|
||||
* instead. Read more about [locators](https://playwright.dev/docs/locators).
|
||||
* @deprecated 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).
|
||||
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
|
||||
* used.
|
||||
* @param text A text to type into a focused element.
|
||||
|
|
@ -9664,7 +9666,7 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
|
|||
* instead.
|
||||
*
|
||||
* 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 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).
|
||||
*
|
||||
* **Usage**
|
||||
* @deprecated Use locator-based
|
||||
* [locator.pressSequentially(text[, options])](https://playwright.dev/docs/api/class-locator#locator-press-sequentially)
|
||||
* instead. Read more about [locators](https://playwright.dev/docs/locators).
|
||||
* @deprecated 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).
|
||||
* @param text A text to type into a focused element.
|
||||
* @param options
|
||||
*/
|
||||
|
|
@ -17715,6 +17718,9 @@ export interface Keyboard {
|
|||
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
|
||||
* [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
|
||||
|
|
@ -17761,6 +17767,11 @@ export interface Keyboard {
|
|||
}): 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.
|
||||
*
|
||||
* To press a special key, like `Control` or `ArrowDown`, use
|
||||
|
|
|
|||
Loading…
Reference in a new issue