From abe97d5273127f85d2268cf617079877686a2462 Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Tue, 24 Aug 2021 19:51:33 +0300 Subject: [PATCH] cherry-pick(release-1.14): deprecate timeout option in isVisible/isHidden methods (#8407) PR #8371 SHA 827a909d36b7e5735d411ad5a4f7e1c91395eb94 Co-authored-by: Dmitry Gozman --- docs/src/api/class-frame.md | 10 ++++++-- docs/src/api/class-locator.md | 10 ++++++-- docs/src/api/class-page.md | 12 ++++++--- src/protocol/channels.ts | 5 ---- src/protocol/protocol.yml | 4 --- src/protocol/validator.ts | 2 -- src/server/frames.ts | 6 ++--- types/types.d.ts | 48 +++++++++++++++++------------------ 8 files changed, 52 insertions(+), 45 deletions(-) diff --git a/docs/src/api/class-frame.md b/docs/src/api/class-frame.md index a1ba9b8fcc..8e5efcd459 100644 --- a/docs/src/api/class-frame.md +++ b/docs/src/api/class-frame.md @@ -919,7 +919,10 @@ Returns whether the element is hidden, the opposite of [visible](./actionability ### param: Frame.isHidden.selector = %%-input-selector-%% ### option: Frame.isHidden.strict = %%-input-strict-%% -### option: Frame.isHidden.timeout = %%-input-timeout-%% +### option: Frame.isHidden.timeout +- `timeout` <[float]> + +**DEPRECATED** This option is ignored. [`method: Frame.isHidden`] does not wait for the element to become hidden and returns immediately. ## async method: Frame.isVisible - returns: <[boolean]> @@ -929,7 +932,10 @@ Returns whether the element is [visible](./actionability.md#visible). [`option: ### param: Frame.isVisible.selector = %%-input-selector-%% ### option: Frame.isVisible.strict = %%-input-strict-%% -### option: Frame.isVisible.timeout = %%-input-timeout-%% +### option: Frame.isVisible.timeout +- `timeout` <[float]> + +**DEPRECATED** This option is ignored. [`method: Frame.isVisible`] does not wait for the element to become visible and returns immediately. ## method: Frame.locator - returns: <[Locator]> diff --git a/docs/src/api/class-locator.md b/docs/src/api/class-locator.md index e4f132a43f..0489e3d35c 100644 --- a/docs/src/api/class-locator.md +++ b/docs/src/api/class-locator.md @@ -557,14 +557,20 @@ Returns whether the element is [enabled](./actionability.md#enabled). Returns whether the element is hidden, the opposite of [visible](./actionability.md#visible). -### option: Locator.isHidden.timeout = %%-input-timeout-%% +### option: Locator.isHidden.timeout +- `timeout` <[float]> + +**DEPRECATED** This option is ignored. [`method: Locator.isHidden`] does not wait for the element to become hidden and returns immediately. ## async method: Locator.isVisible - returns: <[boolean]> Returns whether the element is [visible](./actionability.md#visible). -### option: Locator.isVisible.timeout = %%-input-timeout-%% +### option: Locator.isVisible.timeout +- `timeout` <[float]> + +**DEPRECATED** This option is ignored. [`method: Locator.isVisible`] does not wait for the element to become visible and returns immediately. ## method: Locator.last - returns: <[Locator]> diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md index e6ae6a2472..50a81f4f34 100644 --- a/docs/src/api/class-page.md +++ b/docs/src/api/class-page.md @@ -2026,7 +2026,10 @@ Returns whether the element is hidden, the opposite of [visible](./actionability ### param: Page.isHidden.selector = %%-input-selector-%% ### option: Page.isHidden.strict = %%-input-strict-%% -### option: Page.isHidden.timeout = %%-input-timeout-%% +### option: Page.isHidden.timeout +- `timeout` <[float]> + +**DEPRECATED** This option is ignored. [`method: Page.isHidden`] does not wait for the element to become hidden and returns immediately. ## async method: Page.isVisible - returns: <[boolean]> @@ -2036,7 +2039,10 @@ Returns whether the element is [visible](./actionability.md#visible). [`option: ### param: Page.isVisible.selector = %%-input-selector-%% ### option: Page.isVisible.strict = %%-input-strict-%% -### option: Page.isVisible.timeout = %%-input-timeout-%% +### option: Page.isVisible.timeout +- `timeout` <[float]> + +**DEPRECATED** This option is ignored. [`method: Page.isVisible`] does not wait for the element to become visible and returns immediately. ## property: Page.keyboard - type: <[Keyboard]> @@ -2650,7 +2656,7 @@ page.select_option("select#colors", value=["red", "green", "blue"]) await page.SelectOptionAsync("select#colors", new[] { "blue" }); // single selection matching both the value and the label await page.SelectOptionAsync("select#colors", new[] { new SelectOptionValue() { Label = "blue" } }); -// multiple +// multiple await page.SelectOptionAsync("select#colors", new[] { "red", "green", "blue" }); ``` diff --git a/src/protocol/channels.ts b/src/protocol/channels.ts index f376dcae0f..145bef9dbd 100644 --- a/src/protocol/channels.ts +++ b/src/protocol/channels.ts @@ -1686,11 +1686,9 @@ export type FrameIsEnabledResult = { export type FrameIsHiddenParams = { selector: string, strict?: boolean, - timeout?: number, }; export type FrameIsHiddenOptions = { strict?: boolean, - timeout?: number, }; export type FrameIsHiddenResult = { value: boolean, @@ -1698,11 +1696,9 @@ export type FrameIsHiddenResult = { export type FrameIsVisibleParams = { selector: string, strict?: boolean, - timeout?: number, }; export type FrameIsVisibleOptions = { strict?: boolean, - timeout?: number, }; export type FrameIsVisibleResult = { value: boolean, @@ -3380,7 +3376,6 @@ export const commandsWithTracingSnapshots = new Set([ 'Frame.isChecked', 'Frame.isDisabled', 'Frame.isEnabled', - 'Frame.isHidden', 'Frame.isEditable', 'Frame.press', 'Frame.selectOption', diff --git a/src/protocol/protocol.yml b/src/protocol/protocol.yml index dfae71a9d2..17651bd72e 100644 --- a/src/protocol/protocol.yml +++ b/src/protocol/protocol.yml @@ -1384,17 +1384,13 @@ Frame: parameters: selector: string strict: boolean? - timeout: number? returns: value: boolean - tracing: - snapshot: true isVisible: parameters: selector: string strict: boolean? - timeout: number? returns: value: boolean diff --git a/src/protocol/validator.ts b/src/protocol/validator.ts index b68e103d04..9c405dd0b0 100644 --- a/src/protocol/validator.ts +++ b/src/protocol/validator.ts @@ -699,12 +699,10 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme { scheme.FrameIsHiddenParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tOptional(tNumber), }); scheme.FrameIsVisibleParams = tObject({ selector: tString, strict: tOptional(tBoolean), - timeout: tOptional(tNumber), }); scheme.FrameIsEditableParams = tObject({ selector: tString, diff --git a/src/server/frames.ts b/src/server/frames.ts index 295bc00c47..98df9a7195 100644 --- a/src/server/frames.ts +++ b/src/server/frames.ts @@ -1091,16 +1091,16 @@ export class Frame extends SdkObject { return dom.throwFatalDOMError(dom.throwRetargetableDOMError(result)); } - async isVisible(metadata: CallMetadata, selector: string, options: types.QueryOnSelectorOptions = {}): Promise { + async isVisible(metadata: CallMetadata, selector: string, options: types.StrictOptions = {}): Promise { const controller = new ProgressController(metadata, this); return controller.run(async progress => { progress.log(` checking visibility of "${selector}"`); const element = await this.querySelector(selector, options); return element ? await element.isVisible() : false; - }, this._page._timeoutSettings.timeout(options)); + }, this._page._timeoutSettings.timeout({})); } - async isHidden(metadata: CallMetadata, selector: string, options: types.QueryOnSelectorOptions = {}): Promise { + async isHidden(metadata: CallMetadata, selector: string, options: types.StrictOptions = {}): Promise { return !(await this.isVisible(metadata, selector, options)); } diff --git a/types/types.d.ts b/types/types.d.ts index 76e9d52194..bb93cd80da 100644 --- a/types/types.d.ts +++ b/types/types.d.ts @@ -2033,10 +2033,10 @@ export interface Page { strict?: boolean; /** - * Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by - * using the - * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) - * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods. + * **DEPRECATED** This option is ignored. + * [page.isHidden(selector[, options])](https://playwright.dev/docs/api/class-page#page-is-hidden) does not wait for the + * element to become hidden and returns immediately. + * @deprecated */ timeout?: number; }): Promise; @@ -2055,10 +2055,10 @@ export interface Page { strict?: boolean; /** - * Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by - * using the - * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) - * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods. + * **DEPRECATED** This option is ignored. + * [page.isVisible(selector[, options])](https://playwright.dev/docs/api/class-page#page-is-visible) does not wait for the + * element to become visible and returns immediately. + * @deprecated */ timeout?: number; }): Promise; @@ -4304,10 +4304,10 @@ export interface Frame { strict?: boolean; /** - * Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by - * using the - * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) - * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods. + * **DEPRECATED** This option is ignored. + * [frame.isHidden(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-is-hidden) does not wait for the + * element to become hidden and returns immediately. + * @deprecated */ timeout?: number; }): Promise; @@ -4326,10 +4326,10 @@ export interface Frame { strict?: boolean; /** - * Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by - * using the - * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) - * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods. + * **DEPRECATED** This option is ignored. + * [frame.isVisible(selector[, options])](https://playwright.dev/docs/api/class-frame#frame-is-visible) does not wait for + * the element to become visible and returns immediately. + * @deprecated */ timeout?: number; }): Promise; @@ -7659,10 +7659,10 @@ export interface Locator { */ isHidden(options?: { /** - * Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by - * using the - * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) - * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods. + * **DEPRECATED** This option is ignored. + * [locator.isHidden([options])](https://playwright.dev/docs/api/class-locator#locator-is-hidden) does not wait for the + * element to become hidden and returns immediately. + * @deprecated */ timeout?: number; }): Promise; @@ -7673,10 +7673,10 @@ export interface Locator { */ isVisible(options?: { /** - * Maximum time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout. The default value can be changed by - * using the - * [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout) - * or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout) methods. + * **DEPRECATED** This option is ignored. + * [locator.isVisible([options])](https://playwright.dev/docs/api/class-locator#locator-is-visible) does not wait for the + * element to become visible and returns immediately. + * @deprecated */ timeout?: number; }): Promise;