From 24cb6a28ad1f80e567ed3223618cb019fba75be3 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Thu, 9 Jul 2020 14:22:58 +0100 Subject: [PATCH] chore(docs): document Frame class (#6188) * chore: document Frame class --- new-docs/puppeteer.frame._.md | 6 +- new-docs/puppeteer.frame.__.md | 6 +- new-docs/puppeteer.frame.__eval.md | 20 +- new-docs/puppeteer.frame._detach.md | 15 - new-docs/puppeteer.frame._eval.md | 20 +- new-docs/puppeteer.frame._navigated.md | 22 - ...uppeteer.frame._navigatedwithindocument.md | 22 - new-docs/puppeteer.frame._onlifecycleevent.md | 23 - new-docs/puppeteer.frame._onloadingstopped.md | 15 - new-docs/puppeteer.frame._x.md | 4 +- new-docs/puppeteer.frame.addscripttag.md | 13 +- new-docs/puppeteer.frame.addstyletag.md | 12 +- new-docs/puppeteer.frame.childframes.md | 2 + new-docs/puppeteer.frame.click.md | 18 +- new-docs/puppeteer.frame.content.md | 2 + new-docs/puppeteer.frame.evaluate.md | 8 +- new-docs/puppeteer.frame.evaluatehandle.md | 10 +- new-docs/puppeteer.frame.executioncontext.md | 2 + new-docs/puppeteer.frame.focus.md | 8 +- new-docs/puppeteer.frame.goto.md | 24 +- new-docs/puppeteer.frame.hover.md | 8 +- new-docs/puppeteer.frame.isdetached.md | 2 + new-docs/puppeteer.frame.md | 74 ++- new-docs/puppeteer.frame.name.md | 8 + new-docs/puppeteer.frame.parentframe.md | 2 + new-docs/puppeteer.frame.select.md | 21 +- new-docs/puppeteer.frame.setcontent.md | 6 +- new-docs/puppeteer.frame.tap.md | 10 +- new-docs/puppeteer.frame.title.md | 2 + new-docs/puppeteer.frame.type.md | 23 +- new-docs/puppeteer.frame.url.md | 2 + new-docs/puppeteer.frame.waitfor.md | 14 +- new-docs/puppeteer.frame.waitforfunction.md | 45 +- new-docs/puppeteer.frame.waitfornavigation.md | 19 +- new-docs/puppeteer.frame.waitforselector.md | 34 +- new-docs/puppeteer.frame.waitforxpath.md | 10 +- ...peteer.frameaddscripttagoptions.content.md | 13 + .../puppeteer.frameaddscripttagoptions.md | 22 + ...puppeteer.frameaddscripttagoptions.path.md | 18 + ...puppeteer.frameaddscripttagoptions.type.md | 13 + .../puppeteer.frameaddscripttagoptions.url.md | 13 + ...ppeteer.frameaddstyletagoptions.content.md | 13 + new-docs/puppeteer.frameaddstyletagoptions.md | 21 + .../puppeteer.frameaddstyletagoptions.path.md | 18 + .../puppeteer.frameaddstyletagoptions.url.md | 13 + .../puppeteer.framewaitforfunctionoptions.md | 20 + ...eer.framewaitforfunctionoptions.polling.md | 17 + ...eer.framewaitforfunctionoptions.timeout.md | 13 + new-docs/puppeteer.md | 5 +- new-docs/puppeteer.page.evaluate.md | 43 +- src/common/FrameManager.ts | 547 +++++++++++++++++- src/common/Page.ts | 41 ++ utils/doclint/check_public_api/index.js | 21 + 53 files changed, 1200 insertions(+), 183 deletions(-) delete mode 100644 new-docs/puppeteer.frame._detach.md delete mode 100644 new-docs/puppeteer.frame._navigated.md delete mode 100644 new-docs/puppeteer.frame._navigatedwithindocument.md delete mode 100644 new-docs/puppeteer.frame._onlifecycleevent.md delete mode 100644 new-docs/puppeteer.frame._onloadingstopped.md create mode 100644 new-docs/puppeteer.frameaddscripttagoptions.content.md create mode 100644 new-docs/puppeteer.frameaddscripttagoptions.md create mode 100644 new-docs/puppeteer.frameaddscripttagoptions.path.md create mode 100644 new-docs/puppeteer.frameaddscripttagoptions.type.md create mode 100644 new-docs/puppeteer.frameaddscripttagoptions.url.md create mode 100644 new-docs/puppeteer.frameaddstyletagoptions.content.md create mode 100644 new-docs/puppeteer.frameaddstyletagoptions.md create mode 100644 new-docs/puppeteer.frameaddstyletagoptions.path.md create mode 100644 new-docs/puppeteer.frameaddstyletagoptions.url.md create mode 100644 new-docs/puppeteer.framewaitforfunctionoptions.md create mode 100644 new-docs/puppeteer.framewaitforfunctionoptions.polling.md create mode 100644 new-docs/puppeteer.framewaitforfunctionoptions.timeout.md diff --git a/new-docs/puppeteer.frame._.md b/new-docs/puppeteer.frame._.md index 7cc2811814582..310a73ec135ba 100644 --- a/new-docs/puppeteer.frame._.md +++ b/new-docs/puppeteer.frame._.md @@ -4,6 +4,8 @@ ## Frame.$() method +This method queries the frame for the given selector. + Signature: ```typescript @@ -14,9 +16,11 @@ $(selector: string): Promise; | Parameter | Type | Description | | --- | --- | --- | -| selector | string | | +| selector | string | a selector to query for. | Returns: Promise<[ElementHandle](./puppeteer.elementhandle.md) \| null> +A promise which resolves to an `ElementHandle` pointing at the element, or `null` if it was not found. + diff --git a/new-docs/puppeteer.frame.__.md b/new-docs/puppeteer.frame.__.md index 85377779fe852..5b1bd125da441 100644 --- a/new-docs/puppeteer.frame.__.md +++ b/new-docs/puppeteer.frame.__.md @@ -4,6 +4,8 @@ ## Frame.$$() method +This runs `document.querySelectorAll` in the frame and returns the result. + Signature: ```typescript @@ -14,9 +16,11 @@ $$(selector: string): Promise; | Parameter | Type | Description | | --- | --- | --- | -| selector | string | | +| selector | string | a selector to search for | Returns: Promise<[ElementHandle](./puppeteer.elementhandle.md)\[\]> +An array of element handles pointing to the found frame elements. + diff --git a/new-docs/puppeteer.frame.__eval.md b/new-docs/puppeteer.frame.__eval.md index f441635cca2e8..cc2f0fd7075bb 100644 --- a/new-docs/puppeteer.frame.__eval.md +++ b/new-docs/puppeteer.frame.__eval.md @@ -14,11 +14,25 @@ $$eval(selector: string, pageFunction: (elements: Element[], ...args | Parameter | Type | Description | | --- | --- | --- | -| selector | string | | -| pageFunction | (elements: Element\[\], ...args: unknown\[\]) => ReturnType \| Promise<ReturnType> | | -| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | | +| selector | string | the selector to query for | +| pageFunction | (elements: Element\[\], ...args: unknown\[\]) => ReturnType \| Promise<ReturnType> | the function to be evaluated in the frame's context | +| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | additional arguments to pass to pageFuncton | Returns: Promise<[WrapElementHandle](./puppeteer.wrapelementhandle.md)<ReturnType>> +## Remarks + +This method runs `Array.from(document.querySelectorAll(selector))` within the frame and passes it as the first argument to `pageFunction`. + +If `pageFunction` returns a Promise, then `frame.$$eval` would wait for the promise to resolve and return its value. + +## Example + + +```js +const divsCounts = await frame.$$eval('div', divs => divs.length); + +``` + diff --git a/new-docs/puppeteer.frame._detach.md b/new-docs/puppeteer.frame._detach.md deleted file mode 100644 index 847829c5c0c8e..0000000000000 --- a/new-docs/puppeteer.frame._detach.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [puppeteer](./puppeteer.md) > [Frame](./puppeteer.frame.md) > [\_detach](./puppeteer.frame._detach.md) - -## Frame.\_detach() method - -Signature: - -```typescript -_detach(): void; -``` -Returns: - -void - diff --git a/new-docs/puppeteer.frame._eval.md b/new-docs/puppeteer.frame._eval.md index ee1654dd79335..b936609b1c906 100644 --- a/new-docs/puppeteer.frame._eval.md +++ b/new-docs/puppeteer.frame._eval.md @@ -14,11 +14,25 @@ $eval(selector: string, pageFunction: (element: Element, ...args: un | Parameter | Type | Description | | --- | --- | --- | -| selector | string | | -| pageFunction | (element: Element, ...args: unknown\[\]) => ReturnType \| Promise<ReturnType> | | -| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | | +| selector | string | the selector to query for | +| pageFunction | (element: Element, ...args: unknown\[\]) => ReturnType \| Promise<ReturnType> | the function to be evaluated in the frame's context | +| args | [SerializableOrJSHandle](./puppeteer.serializableorjshandle.md)\[\] | additional arguments to pass to pageFuncton | Returns: Promise<[WrapElementHandle](./puppeteer.wrapelementhandle.md)<ReturnType>> +## Remarks + +This method runs `document.querySelector` within the frame and passes it as the first argument to `pageFunction`. + +If `pageFunction` returns a Promise, then `frame.$eval` would wait for the promise to resolve and return its value. + +## Example + + +```js +const searchValue = await frame.$eval('#search', el => el.value); + +``` + diff --git a/new-docs/puppeteer.frame._navigated.md b/new-docs/puppeteer.frame._navigated.md deleted file mode 100644 index 52aca09a989f3..0000000000000 --- a/new-docs/puppeteer.frame._navigated.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [puppeteer](./puppeteer.md) > [Frame](./puppeteer.frame.md) > [\_navigated](./puppeteer.frame._navigated.md) - -## Frame.\_navigated() method - -Signature: - -```typescript -_navigated(framePayload: Protocol.Page.Frame): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| framePayload | Protocol.Page.Frame | | - -Returns: - -void - diff --git a/new-docs/puppeteer.frame._navigatedwithindocument.md b/new-docs/puppeteer.frame._navigatedwithindocument.md deleted file mode 100644 index 8274974a5cb0e..0000000000000 --- a/new-docs/puppeteer.frame._navigatedwithindocument.md +++ /dev/null @@ -1,22 +0,0 @@ - - -[Home](./index.md) > [puppeteer](./puppeteer.md) > [Frame](./puppeteer.frame.md) > [\_navigatedWithinDocument](./puppeteer.frame._navigatedwithindocument.md) - -## Frame.\_navigatedWithinDocument() method - -Signature: - -```typescript -_navigatedWithinDocument(url: string): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| url | string | | - -Returns: - -void - diff --git a/new-docs/puppeteer.frame._onlifecycleevent.md b/new-docs/puppeteer.frame._onlifecycleevent.md deleted file mode 100644 index ead8232117269..0000000000000 --- a/new-docs/puppeteer.frame._onlifecycleevent.md +++ /dev/null @@ -1,23 +0,0 @@ - - -[Home](./index.md) > [puppeteer](./puppeteer.md) > [Frame](./puppeteer.frame.md) > [\_onLifecycleEvent](./puppeteer.frame._onlifecycleevent.md) - -## Frame.\_onLifecycleEvent() method - -Signature: - -```typescript -_onLifecycleEvent(loaderId: string, name: string): void; -``` - -## Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| loaderId | string | | -| name | string | | - -Returns: - -void - diff --git a/new-docs/puppeteer.frame._onloadingstopped.md b/new-docs/puppeteer.frame._onloadingstopped.md deleted file mode 100644 index f5db1400a76a9..0000000000000 --- a/new-docs/puppeteer.frame._onloadingstopped.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [puppeteer](./puppeteer.md) > [Frame](./puppeteer.frame.md) > [\_onLoadingStopped](./puppeteer.frame._onloadingstopped.md) - -## Frame.\_onLoadingStopped() method - -Signature: - -```typescript -_onLoadingStopped(): void; -``` -Returns: - -void - diff --git a/new-docs/puppeteer.frame._x.md b/new-docs/puppeteer.frame._x.md index dded77cc4a78c..169ff74f77fb0 100644 --- a/new-docs/puppeteer.frame._x.md +++ b/new-docs/puppeteer.frame._x.md @@ -4,6 +4,8 @@ ## Frame.$x() method +This method evaluates the given XPath expression and returns the results. + Signature: ```typescript @@ -14,7 +16,7 @@ $x(expression: string): Promise; | Parameter | Type | Description | | --- | --- | --- | -| expression | string | | +| expression | string | the XPath expression to evaluate. | Returns: diff --git a/new-docs/puppeteer.frame.addscripttag.md b/new-docs/puppeteer.frame.addscripttag.md index f1fe45de1d073..9aa7cf609aaa2 100644 --- a/new-docs/puppeteer.frame.addscripttag.md +++ b/new-docs/puppeteer.frame.addscripttag.md @@ -4,24 +4,23 @@ ## Frame.addScriptTag() method +Adds a `