From 32400954c50cbddc48468ad118c3f8a47653b9d3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 Sep 2022 19:43:39 +0200 Subject: [PATCH] fix: add Page.getDefaultTimeout getter (#8903) Closes #8901 --- docs/api/puppeteer.page.getdefaulttimeout.md | 19 +++++++++++++++++++ docs/api/puppeteer.page.md | 1 + src/common/Page.ts | 7 +++++++ 3 files changed, 27 insertions(+) create mode 100644 docs/api/puppeteer.page.getdefaulttimeout.md diff --git a/docs/api/puppeteer.page.getdefaulttimeout.md b/docs/api/puppeteer.page.getdefaulttimeout.md new file mode 100644 index 0000000000000..a44029aaee408 --- /dev/null +++ b/docs/api/puppeteer.page.getdefaulttimeout.md @@ -0,0 +1,19 @@ +--- +sidebar_label: Page.getDefaultTimeout +--- + +# Page.getDefaultTimeout() method + +**Signature:** + +```typescript +class Page { + getDefaultTimeout(): number; +} +``` + +**Returns:** + +number + +Maximum time in milliseconds. diff --git a/docs/api/puppeteer.page.md b/docs/api/puppeteer.page.md index f6d63edbcdbe3..b3f47b2f801f9 100644 --- a/docs/api/puppeteer.page.md +++ b/docs/api/puppeteer.page.md @@ -108,6 +108,7 @@ page.off('request', logRequest); | [exposeFunction(name, pptrFunction)](./puppeteer.page.exposefunction.md) | |

The method adds a function called name on the page's window object. When called, the function executes puppeteerFunction in node.js and returns a Promise which resolves to the return value of puppeteerFunction.

If the puppeteerFunction returns a Promise, it will be awaited.

:::note

Functions installed via page.exposeFunction survive navigations.

:::note

| | [focus(selector)](./puppeteer.page.focus.md) | | This method fetches an element with selector and focuses it. If there's no element matching selector, the method throws an error. | | [frames()](./puppeteer.page.frames.md) | | | +| [getDefaultTimeout()](./puppeteer.page.getdefaulttimeout.md) | | | | [goBack(options)](./puppeteer.page.goback.md) | | This method navigate to the previous page in history. | | [goForward(options)](./puppeteer.page.goforward.md) | | This method navigate to the next page in history. | | [goto(url, options)](./puppeteer.page.goto.md) | | | diff --git a/src/common/Page.ts b/src/common/Page.ts index 0391891dc114a..e97517d3544ac 100644 --- a/src/common/Page.ts +++ b/src/common/Page.ts @@ -1042,6 +1042,13 @@ export class Page extends EventEmitter { this.#timeoutSettings.setDefaultTimeout(timeout); } + /** + * @returns Maximum time in milliseconds. + */ + getDefaultTimeout(): number { + return this.#timeoutSettings.timeout(); + } + /** * Runs `document.querySelector` within the page. If no element matches the * selector, the return value resolves to `null`.