Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs: update deprecation messages for type() methods (#26912)
Dmitry Gozmanabea8f4d1c8c
diff --git a/docs/src/api/class-elementhandle.md b/docs/src/api/class-elementhandle.mdindex 400afdd6c8..7f2641999a 100644--- a/docs/src/api/class-elementhandle.md+++ b/docs/src/api/class-elementhandle.md@@ -513,7 +513,7 @@ This method waits for [actionability](../actionability.md) checks, focuses the eIf 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.diff --git a/docs/src/api/class-frame.md b/docs/src/api/class-frame.mdindex 34688ed87f..c607b4adc5 100644--- a/docs/src/api/class-frame.md+++ b/docs/src/api/class-frame.md@@ -839,7 +839,7 @@ This method waits for an element matching [`param: selector`], waits for [actionIf 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 tosend fine-grained keyboard events. To fill values in form fields, use [`method: Frame.fill`].diff --git a/docs/src/api/class-keyboard.md b/docs/src/api/class-keyboard.mdindex 5144016815..87ba51ec37 100644--- a/docs/src/api/class-keyboard.md+++ b/docs/src/api/class-keyboard.md@@ -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 togenerate 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`].diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.mdindex b316e2a489..7c0e532d17 100644--- a/docs/src/api/class-page.md+++ b/docs/src/api/class-page.md@@ -2096,7 +2096,7 @@ This method waits for an element matching [`param: selector`], waits for [actionIf 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 sendfine-grained keyboard events. To fill values in form fields, use [`method: Page.fill`].diff --git a/docs/src/input.md b/docs/src/input.mdindex d69bd3c043..20efdefb14 100644--- a/docs/src/input.md+++ b/docs/src/input.md@@ -361,7 +361,7 @@ await page.GetByRole(AriaRole.Button).DispatchEventAsync("click");## Type characters-:::tip+:::cautionMost 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.:::diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.tsindex d8f5758d5c..3e89c6ef1c 100644--- a/packages/playwright-core/types/types.d.ts+++ b/packages/playwright-core/types/types.d.ts@@ -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