fix: deprecate waitForTimeout (#8793)

This commit is contained in:
jrandolf 2022-08-16 08:24:25 +02:00 committed by GitHub
parent b5da718e2e
commit 8f612d5ff8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 14 deletions

View File

@ -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) | | |

View File

@ -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:**
@ -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);
```

View File

@ -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

View File

@ -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:**
@ -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

View File

@ -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
@ -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 => {

View File

@ -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
*