Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecate waitForTimeout #8793

Merged
merged 1 commit into from Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/puppeteer.frame.md
Expand Up @@ -93,5 +93,5 @@ console.log(text);
| [waitForFunction(pageFunction, options, args)](./puppeteer.frame.waitforfunction.md) | | |
| [waitForNavigation(options)](./puppeteer.frame.waitfornavigation.md) | | <p>Waits for the frame to navigate. It is useful for when you run code which will indirectly cause the frame to navigate.</p><p>Usage of the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.</p> |
| [waitForSelector(selector, options)](./puppeteer.frame.waitforselector.md) | | <p>Waits for an element matching the given selector to appear in the frame.</p><p>This method works across navigations.</p> |
| [waitForTimeout(milliseconds)](./puppeteer.frame.waitfortimeout.md) | | Causes your script to wait for the given number of milliseconds. |
| [waitForTimeout(milliseconds)](./puppeteer.frame.waitfortimeout.md) | | |
| [waitForXPath(xpath, options)](./puppeteer.frame.waitforxpath.md) | | |
8 changes: 4 additions & 4 deletions docs/api/puppeteer.frame.waitfortimeout.md
Expand Up @@ -6,9 +6,9 @@ sidebar_label: Frame.waitForTimeout

> Warning: This API is now obsolete.
>
> DO NOT USE.

Causes your script to wait for the given number of milliseconds.
> Use `new Promise(r => setTimeout(r, milliseconds));`.
>
> Causes your script to wait for the given number of milliseconds.

**Signature:**

Expand Down Expand Up @@ -36,6 +36,6 @@ It's generally recommended to not wait for a number of seconds, but instead use

Wait for 1 second:

```
```ts
await frame.waitForTimeout(1000);
```
2 changes: 1 addition & 1 deletion docs/api/puppeteer.page.md
Expand Up @@ -174,7 +174,7 @@ const puppeteer = require('puppeteer');
```

|
| [waitForTimeout(milliseconds)](./puppeteer.page.waitfortimeout.md) | | Causes your script to wait for the given number of milliseconds. |
| [waitForTimeout(milliseconds)](./puppeteer.page.waitfortimeout.md) | | |
| [waitForXPath(xpath, options)](./puppeteer.page.waitforxpath.md) | | <p>Wait for the <code>xpath</code> to appear in page. If at the moment of calling the method the <code>xpath</code> already exists, the method will return immediately. If the <code>xpath</code> doesn't appear after the <code>timeout</code> milliseconds of waiting, the function will throw.</p><p>This method works across navigation</p>

```ts
Expand Down
8 changes: 6 additions & 2 deletions docs/api/puppeteer.page.waitfortimeout.md
Expand Up @@ -4,7 +4,11 @@ sidebar_label: Page.waitForTimeout

# Page.waitForTimeout() method

Causes your script to wait for the given number of milliseconds.
> Warning: This API is now obsolete.
>
> Use `new Promise(r => setTimeout(r, milliseconds));`.
>
> Causes your script to wait for the given number of milliseconds.

**Signature:**

Expand All @@ -26,7 +30,7 @@ Promise&lt;void&gt;

## Remarks

It's generally recommended to not wait for a number of seconds, but instead use [Page.waitForSelector()](./puppeteer.page.waitforselector.md), [Page.waitForXPath()](./puppeteer.page.waitforxpath.md) or [Page.waitForFunction()](./puppeteer.page.waitforfunction.md) to wait for exactly the conditions you want.
It's generally recommended to not wait for a number of seconds, but instead use [Frame.waitForSelector()](./puppeteer.frame.waitforselector.md), [Frame.waitForXPath()](./puppeteer.frame.waitforxpath.md) or [Frame.waitForFunction()](./puppeteer.frame.waitforfunction.md) to wait for exactly the conditions you want.

## Example

Expand Down
6 changes: 3 additions & 3 deletions src/common/FrameManager.ts
Expand Up @@ -1402,6 +1402,8 @@ export class Frame {
}

/**
* @deprecated Use `new Promise(r => setTimeout(r, milliseconds));`.
*
* Causes your script to wait for the given number of milliseconds.
*
* @remarks
Expand All @@ -1413,13 +1415,11 @@ export class Frame {
*
* Wait for 1 second:
*
* ```
* ```ts
* await frame.waitForTimeout(1000);
* ```
*
* @param milliseconds - the number of milliseconds to wait.
*
* @deprecated DO NOT USE.
*/
waitForTimeout(milliseconds: number): Promise<void> {
return new Promise(resolve => {
Expand Down
7 changes: 4 additions & 3 deletions src/common/Page.ts
Expand Up @@ -3318,13 +3318,14 @@ export class Page extends EventEmitter {
}

/**
* @deprecated Use `new Promise(r => setTimeout(r, milliseconds));`.
*
* Causes your script to wait for the given number of milliseconds.
*
* @remarks
*
* It's generally recommended to not wait for a number of seconds, but instead
* use {@link Page.waitForSelector}, {@link Page.waitForXPath} or
* {@link Page.waitForFunction} to wait for exactly the conditions you want.
* use {@link Frame.waitForSelector}, {@link Frame.waitForXPath} or
* {@link Frame.waitForFunction} to wait for exactly the conditions you want.
*
* @example
*
Expand Down