Skip to content

Commit

Permalink
New-docs for waitForTimeout()
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfranklin committed Jul 24, 2020
1 parent 2e47fca commit aa34081
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 7 deletions.
2 changes: 0 additions & 2 deletions docs/api.md
Expand Up @@ -2256,7 +2256,6 @@ const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
let currentURL;
page.waitForTimeout(1000)
.then(() => console.log('Waited a second!'));

Expand Down Expand Up @@ -3196,7 +3195,6 @@ const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
let currentURL;
page.mainFrame()
.waitForTimeout(1000)
.then(() => console.log('Waited a second!'));
Expand Down
1 change: 1 addition & 0 deletions new-docs/puppeteer.frame.md
Expand Up @@ -92,5 +92,6 @@ console.log(text);
| [waitForFunction(pageFunction, options, args)](./puppeteer.frame.waitforfunction.md) | | |
| [waitForNavigation(options)](./puppeteer.frame.waitfornavigation.md) | | |
| [waitForSelector(selector, options)](./puppeteer.frame.waitforselector.md) | | |
| [waitForTimeout(milliseconds)](./puppeteer.frame.waitfortimeout.md) | | Causes your script to wait for the given number of milliseconds. |
| [waitForXPath(xpath, options)](./puppeteer.frame.waitforxpath.md) | | |

5 changes: 5 additions & 0 deletions new-docs/puppeteer.frame.waitfor.md
Expand Up @@ -4,6 +4,11 @@

## Frame.waitFor() method

> Warning: This API is now obsolete.
>
> Don't use this method directly. Instead use the more explicit methods available: [Frame.waitForSelector()](./puppeteer.frame.waitforselector.md)<!-- -->, [Frame.waitForXPath()](./puppeteer.frame.waitforxpath.md)<!-- -->, [Frame.waitForFunction()](./puppeteer.frame.waitforfunction.md) or [Frame.waitForTimeout()](./puppeteer.frame.waitfortimeout.md)<!-- -->.
>
<b>Signature:</b>

```typescript
Expand Down
37 changes: 37 additions & 0 deletions new-docs/puppeteer.frame.waitfortimeout.md
@@ -0,0 +1,37 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [puppeteer](./puppeteer.md) &gt; [Frame](./puppeteer.frame.md) &gt; [waitForTimeout](./puppeteer.frame.waitfortimeout.md)

## Frame.waitForTimeout() method

Causes your script to wait for the given number of milliseconds.

<b>Signature:</b>

```typescript
waitForTimeout(milliseconds: number): Promise<void>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| milliseconds | number | the number of milliseconds to wait. |

<b>Returns:</b>

Promise&lt;void&gt;

## Remarks

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

Wait for 1 second:

```
await frame.waitForTimeout(1000);
```

1 change: 1 addition & 0 deletions new-docs/puppeteer.page.md
Expand Up @@ -138,6 +138,7 @@ page.off('request', logRequest);
| [waitForRequest(urlOrPredicate, options)](./puppeteer.page.waitforrequest.md) | | |
| [waitForResponse(urlOrPredicate, options)](./puppeteer.page.waitforresponse.md) | | |
| [waitForSelector(selector, options)](./puppeteer.page.waitforselector.md) | | |
| [waitForTimeout(milliseconds)](./puppeteer.page.waitfortimeout.md) | | Causes your script to wait for the given number of milliseconds. |
| [waitForXPath(xpath, options)](./puppeteer.page.waitforxpath.md) | | |
| [workers()](./puppeteer.page.workers.md) | | |
19 changes: 16 additions & 3 deletions new-docs/puppeteer.page.waitfor.md
Expand Up @@ -4,6 +4,11 @@

## Page.waitFor() method

> Warning: This API is now obsolete.
>
> Don't use this method directly. Instead use the more explicit methods available: [Page.waitForSelector()](./puppeteer.page.waitforselector.md)<!-- -->, [Page.waitForXPath()](./puppeteer.page.waitforxpath.md)<!-- -->, [Page.waitForFunction()](./puppeteer.page.waitforfunction.md) or [Page.waitForTimeout()](./puppeteer.page.waitfortimeout.md)<!-- -->.
>
<b>Signature:</b>

```typescript
Expand All @@ -19,11 +24,19 @@ waitFor(selectorOrFunctionOrTimeout: string | number | Function, options?: {

| Parameter | Type | Description |
| --- | --- | --- |
| selectorOrFunctionOrTimeout | string \| number \| Function | |
| options | { visible?: boolean; hidden?: boolean; timeout?: number; polling?: string \| number; } | |
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | |
| selectorOrFunctionOrTimeout | string \| number \| Function | a selector, predicate or timeout to wait for. |
| options | { visible?: boolean; hidden?: boolean; timeout?: number; polling?: string \| number; } | optional waiting parameters. |
| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)<!-- -->\[\] | arguments to pass to <code>pageFunction</code>. |

<b>Returns:</b>

Promise&lt;[JSHandle](./puppeteer.jshandle.md)<!-- -->&gt;

## Remarks

This method behaves differently depending on the first parameter. If it's a `string`<!-- -->, it will be treated as a `selector` or `xpath` (if the string starts with `//`<!-- -->). This method then is a shortcut for [Page.waitForSelector()](./puppeteer.page.waitforselector.md) or [Page.waitForXPath()](./puppeteer.page.waitforxpath.md)<!-- -->.

If the first argument is a function this method is a shortcut for [Page.waitForFunction()](./puppeteer.page.waitforfunction.md)<!-- -->.

If the first argument is a `number`<!-- -->, it's treated as a timeout in milliseconds and the method returns a promise which resolves after the timeout.

37 changes: 37 additions & 0 deletions new-docs/puppeteer.page.waitfortimeout.md
@@ -0,0 +1,37 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [puppeteer](./puppeteer.md) &gt; [Page](./puppeteer.page.md) &gt; [waitForTimeout](./puppeteer.page.waitfortimeout.md)

## Page.waitForTimeout() method

Causes your script to wait for the given number of milliseconds.

<b>Signature:</b>

```typescript
waitForTimeout(milliseconds: number): Promise<void>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| milliseconds | number | the number of milliseconds to wait. |

<b>Returns:</b>

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.

## Example

Wait for 1 second:

```
await page.waitForTimeout(1000);
```

2 changes: 1 addition & 1 deletion src/common/FrameManager.ts
Expand Up @@ -1036,7 +1036,7 @@ export class Frame {
* @param options - optional waiting parameters.
* @param args - arguments to pass to `pageFunction`.
*
* @deprecated don't use this method directly. Instead use the more explicit
* @deprecated Don't use this method directly. Instead use the more explicit
* methods available: {@link Frame.waitForSelector},
* {@link Frame.waitForXPath}, {@link Frame.waitForFunction} or
* {@link Frame.waitForTimeout}.
Expand Down
2 changes: 1 addition & 1 deletion src/common/Page.ts
Expand Up @@ -1877,7 +1877,7 @@ export class Page extends EventEmitter {
* @param options - optional waiting parameters.
* @param args - arguments to pass to `pageFunction`.
*
* @deprecated don't use this method directly. Instead use the more explicit
* @deprecated Don't use this method directly. Instead use the more explicit
* methods available: {@link Page.waitForSelector},
* {@link Page.waitForXPath}, {@link Page.waitForFunction} or
* {@link Page.waitForTimeout}.
Expand Down

0 comments on commit aa34081

Please sign in to comment.