From e8c8852c0038c7f2a407b70192a365ac04452c81 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 13 Dec 2023 20:06:01 -0800 Subject: [PATCH] chore: discourage methods on ElementHandle (#28637) Mirrors the deprecations from page.* over to ElementHandle. --- docs/src/api/class-elementhandle.md | 35 +++++ packages/playwright-core/types/types.d.ts | 152 ++++++++++++++++++++++ 2 files changed, 187 insertions(+) diff --git a/docs/src/api/class-elementhandle.md b/docs/src/api/class-elementhandle.md index df73e558d0..12edbe1817 100644 --- a/docs/src/api/class-elementhandle.md +++ b/docs/src/api/class-elementhandle.md @@ -156,6 +156,7 @@ await page.Mouse.ClickAsync(box.X + box.Width / 2, box.Y + box.Height / 2); ## async method: ElementHandle.check * since: v1.8 +* discouraged: Use locator-based [`method: Locator.check`] instead. Read more about [locators](../locators.md). This method checks the element by performing the following steps: 1. Ensure that element is a checkbox or a radio input. If not, this method throws. If the element is already @@ -191,6 +192,7 @@ When all steps combined have not finished during the specified [`option: timeout ## async method: ElementHandle.click * since: v1.8 +* discouraged: Use locator-based [`method: Locator.click`] instead. Read more about [locators](../locators.md). This method clicks the element by performing the following steps: 1. Wait for [actionability](../actionability.md) checks on the element, unless [`option: force`] option is set. @@ -241,6 +243,7 @@ Returns the content frame for element handles referencing iframe nodes, or `null ## async method: ElementHandle.dblclick * since: v1.8 +* discouraged: Use locator-based [`method: Locator.dblclick`] instead. Read more about [locators](../locators.md). * langs: - alias-csharp: DblClickAsync @@ -289,6 +292,7 @@ When all steps combined have not finished during the specified [`option: timeout ## async method: ElementHandle.dispatchEvent * since: v1.8 +* discouraged: Use locator-based [`method: Locator.dispatchEvent`] instead. Read more about [locators](../locators.md). The snippet below dispatches the `click` event on the element. Regardless of the visibility state of the element, `click` is dispatched. This is equivalent to calling @@ -383,6 +387,9 @@ Optional event-specific initialization properties. ## async method: ElementHandle.evalOnSelector * since: v1.9 +* discouraged: This method does not wait for the element to pass actionability + checks and therefore can lead to the flaky tests. Use [`method: Locator.evaluate`], + other [Locator] helper methods or web-first assertions instead. * langs: - alias-python: eval_on_selector - alias-js: $eval @@ -445,6 +452,8 @@ Optional argument to pass to [`param: expression`]. ## async method: ElementHandle.evalOnSelectorAll * since: v1.9 +* discouraged: In most cases, [`method: Locator.evaluateAll`], + other [Locator] helper methods and web-first assertions do a better job. * langs: - alias-python: eval_on_selector_all - alias-js: $$eval @@ -511,6 +520,7 @@ Optional argument to pass to [`param: expression`]. ## async method: ElementHandle.fill * since: v1.8 +* discouraged: Use locator-based [`method: Locator.fill`] instead. Read more about [locators](../locators.md). 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. @@ -538,11 +548,13 @@ Value to set for the ``, `