docs(api): update ordering for $eval and $$eval (#1623)
This commit is contained in:
parent
c218d8c25f
commit
1f0b7bff04
106
docs/api.md
106
docs/api.md
|
|
@ -643,8 +643,8 @@ page.removeListener('request', logRequest);
|
||||||
- [event: 'worker'](#event-worker)
|
- [event: 'worker'](#event-worker)
|
||||||
- [page.$(selector)](#pageselector)
|
- [page.$(selector)](#pageselector)
|
||||||
- [page.$$(selector)](#pageselector-1)
|
- [page.$$(selector)](#pageselector-1)
|
||||||
- [page.$$eval(selector, pageFunction[, arg])](#pageevalselector-pagefunction-arg)
|
- [page.$eval(selector, pageFunction[, arg])](#pageevalselector-pagefunction-arg)
|
||||||
- [page.$eval(selector, pageFunction[, arg])](#pageevalselector-pagefunction-arg-1)
|
- [page.$$eval(selector, pageFunction[, arg])](#pageevalselector-pagefunction-arg-1)
|
||||||
- [page.accessibility](#pageaccessibility)
|
- [page.accessibility](#pageaccessibility)
|
||||||
- [page.addInitScript(script[, arg])](#pageaddinitscriptscript-arg)
|
- [page.addInitScript(script[, arg])](#pageaddinitscriptscript-arg)
|
||||||
- [page.addScriptTag(options)](#pageaddscripttagoptions)
|
- [page.addScriptTag(options)](#pageaddscripttagoptions)
|
||||||
|
|
@ -827,21 +827,6 @@ The method runs `document.querySelectorAll` within the page. If no elements matc
|
||||||
|
|
||||||
Shortcut for [page.mainFrame().$$(selector)](#frameselector-1).
|
Shortcut for [page.mainFrame().$$(selector)](#frameselector-1).
|
||||||
|
|
||||||
#### page.$$eval(selector, pageFunction[, arg])
|
|
||||||
- `selector` <[string]> A selector to query page for
|
|
||||||
- `pageFunction` <[function]\([Array]<[Element]>\)> Function to be evaluated in browser context
|
|
||||||
- `arg` <[Serializable]|[JSHandle]> Optional argument to pass to `pageFunction`
|
|
||||||
- returns: <[Promise]<[Serializable]>> Promise which resolves to the return value of `pageFunction`
|
|
||||||
|
|
||||||
This method runs `Array.from(document.querySelectorAll(selector))` within the page and passes it as the first argument to `pageFunction`.
|
|
||||||
|
|
||||||
If `pageFunction` returns a [Promise], then `page.$$eval` would wait for the promise to resolve and return its value.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
```js
|
|
||||||
const divsCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### page.$eval(selector, pageFunction[, arg])
|
#### page.$eval(selector, pageFunction[, arg])
|
||||||
- `selector` <[string]> A selector to query page for
|
- `selector` <[string]> A selector to query page for
|
||||||
- `pageFunction` <[function]\([Element]\)> Function to be evaluated in browser context
|
- `pageFunction` <[function]\([Element]\)> Function to be evaluated in browser context
|
||||||
|
|
@ -861,6 +846,21 @@ const html = await page.$eval('.main-container', (e, suffix) => e.outerHTML + su
|
||||||
|
|
||||||
Shortcut for [page.mainFrame().$eval(selector, pageFunction)](#frameevalselector-pagefunction-arg).
|
Shortcut for [page.mainFrame().$eval(selector, pageFunction)](#frameevalselector-pagefunction-arg).
|
||||||
|
|
||||||
|
#### page.$$eval(selector, pageFunction[, arg])
|
||||||
|
- `selector` <[string]> A selector to query page for
|
||||||
|
- `pageFunction` <[function]\([Array]<[Element]>\)> Function to be evaluated in browser context
|
||||||
|
- `arg` <[Serializable]|[JSHandle]> Optional argument to pass to `pageFunction`
|
||||||
|
- returns: <[Promise]<[Serializable]>> Promise which resolves to the return value of `pageFunction`
|
||||||
|
|
||||||
|
This method runs `Array.from(document.querySelectorAll(selector))` within the page and passes it as the first argument to `pageFunction`.
|
||||||
|
|
||||||
|
If `pageFunction` returns a [Promise], then `page.$$eval` would wait for the promise to resolve and return its value.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
```js
|
||||||
|
const divsCounts = await page.$$eval('div', (divs, min) => divs.length >= min, 10);
|
||||||
|
```
|
||||||
|
|
||||||
#### page.accessibility
|
#### page.accessibility
|
||||||
- returns: <[Accessibility]>
|
- returns: <[Accessibility]>
|
||||||
|
|
||||||
|
|
@ -1862,8 +1862,8 @@ An example of getting text from an iframe element:
|
||||||
<!-- GEN:toc -->
|
<!-- GEN:toc -->
|
||||||
- [frame.$(selector)](#frameselector)
|
- [frame.$(selector)](#frameselector)
|
||||||
- [frame.$$(selector)](#frameselector-1)
|
- [frame.$$(selector)](#frameselector-1)
|
||||||
- [frame.$$eval(selector, pageFunction[, arg])](#frameevalselector-pagefunction-arg)
|
- [frame.$eval(selector, pageFunction[, arg])](#frameevalselector-pagefunction-arg)
|
||||||
- [frame.$eval(selector, pageFunction[, arg])](#frameevalselector-pagefunction-arg-1)
|
- [frame.$$eval(selector, pageFunction[, arg])](#frameevalselector-pagefunction-arg-1)
|
||||||
- [frame.addScriptTag(options)](#frameaddscripttagoptions)
|
- [frame.addScriptTag(options)](#frameaddscripttagoptions)
|
||||||
- [frame.addStyleTag(options)](#frameaddstyletagoptions)
|
- [frame.addStyleTag(options)](#frameaddstyletagoptions)
|
||||||
- [frame.check(selector, [options])](#framecheckselector-options)
|
- [frame.check(selector, [options])](#framecheckselector-options)
|
||||||
|
|
@ -1907,21 +1907,6 @@ The method queries frame for the selector. If there's no such element within the
|
||||||
|
|
||||||
The method runs `document.querySelectorAll` within the frame. If no elements match the selector, the return value resolves to `[]`.
|
The method runs `document.querySelectorAll` within the frame. If no elements match the selector, the return value resolves to `[]`.
|
||||||
|
|
||||||
#### frame.$$eval(selector, pageFunction[, arg])
|
|
||||||
- `selector` <[string]> A selector to query frame for
|
|
||||||
- `pageFunction` <[function]\([Array]<[Element]>\)> Function to be evaluated in browser context
|
|
||||||
- `arg` <[Serializable]|[JSHandle]> Optional argument to pass to `pageFunction`
|
|
||||||
- returns: <[Promise]<[Serializable]>> Promise which resolves to the return value of `pageFunction`
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
```js
|
|
||||||
const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### frame.$eval(selector, pageFunction[, arg])
|
#### frame.$eval(selector, pageFunction[, arg])
|
||||||
- `selector` <[string]> A selector to query frame for
|
- `selector` <[string]> A selector to query frame for
|
||||||
- `pageFunction` <[function]\([Element]\)> Function to be evaluated in browser context
|
- `pageFunction` <[function]\([Element]\)> Function to be evaluated in browser context
|
||||||
|
|
@ -1939,6 +1924,21 @@ const preloadHref = await frame.$eval('link[rel=preload]', el => el.href);
|
||||||
const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
const html = await frame.$eval('.main-container', (e, suffix) => e.outerHTML + suffix, 'hello');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### frame.$$eval(selector, pageFunction[, arg])
|
||||||
|
- `selector` <[string]> A selector to query frame for
|
||||||
|
- `pageFunction` <[function]\([Array]<[Element]>\)> Function to be evaluated in browser context
|
||||||
|
- `arg` <[Serializable]|[JSHandle]> Optional argument to pass to `pageFunction`
|
||||||
|
- returns: <[Promise]<[Serializable]>> Promise which resolves to the return value of `pageFunction`
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
```js
|
||||||
|
const divsCounts = await frame.$$eval('div', (divs, min) => divs.length >= min, 10);
|
||||||
|
```
|
||||||
|
|
||||||
#### frame.addScriptTag(options)
|
#### frame.addScriptTag(options)
|
||||||
- `options` <[Object]>
|
- `options` <[Object]>
|
||||||
- `url` <[string]> URL of a script to be added.
|
- `url` <[string]> URL of a script to be added.
|
||||||
|
|
@ -2472,8 +2472,8 @@ ElementHandle instances can be used as an argument in [`page.$eval()`](#pageeval
|
||||||
<!-- GEN:toc -->
|
<!-- GEN:toc -->
|
||||||
- [elementHandle.$(selector)](#elementhandleselector)
|
- [elementHandle.$(selector)](#elementhandleselector)
|
||||||
- [elementHandle.$$(selector)](#elementhandleselector-1)
|
- [elementHandle.$$(selector)](#elementhandleselector-1)
|
||||||
- [elementHandle.$$eval(selector, pageFunction[, arg])](#elementhandleevalselector-pagefunction-arg)
|
- [elementHandle.$eval(selector, pageFunction[, arg])](#elementhandleevalselector-pagefunction-arg)
|
||||||
- [elementHandle.$eval(selector, pageFunction[, arg])](#elementhandleevalselector-pagefunction-arg-1)
|
- [elementHandle.$$eval(selector, pageFunction[, arg])](#elementhandleevalselector-pagefunction-arg-1)
|
||||||
- [elementHandle.boundingBox()](#elementhandleboundingbox)
|
- [elementHandle.boundingBox()](#elementhandleboundingbox)
|
||||||
- [elementHandle.check([options])](#elementhandlecheckoptions)
|
- [elementHandle.check([options])](#elementhandlecheckoptions)
|
||||||
- [elementHandle.click([options])](#elementhandleclickoptions)
|
- [elementHandle.click([options])](#elementhandleclickoptions)
|
||||||
|
|
@ -2514,6 +2514,23 @@ The method runs `element.querySelector` within the page. If no element matches t
|
||||||
|
|
||||||
The method runs `element.querySelectorAll` within the page. If no elements match the selector, the return value resolves to `[]`.
|
The method runs `element.querySelectorAll` within the page. If no elements match the selector, the return value resolves to `[]`.
|
||||||
|
|
||||||
|
#### elementHandle.$eval(selector, pageFunction[, arg])
|
||||||
|
- `selector` <[string]> A selector to query page for
|
||||||
|
- `pageFunction` <[function]\([Element]\)> Function to be evaluated in browser context
|
||||||
|
- `arg` <[Serializable]|[JSHandle]> Optional argument to pass to `pageFunction`
|
||||||
|
- returns: <[Promise]<[Serializable]>> Promise which resolves to the return value of `pageFunction`
|
||||||
|
|
||||||
|
This method runs `document.querySelector` within the element and passes it as the first argument to `pageFunction`. If there's no element matching `selector`, the method throws an error.
|
||||||
|
|
||||||
|
If `pageFunction` returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return its value.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
```js
|
||||||
|
const tweetHandle = await page.$('.tweet');
|
||||||
|
expect(await tweetHandle.$eval('.like', node => node.innerText)).toBe('100');
|
||||||
|
expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
|
||||||
|
```
|
||||||
|
|
||||||
#### elementHandle.$$eval(selector, pageFunction[, arg])
|
#### elementHandle.$$eval(selector, pageFunction[, arg])
|
||||||
- `selector` <[string]> A selector to query page for
|
- `selector` <[string]> A selector to query page for
|
||||||
- `pageFunction` <[function]\([Array]<[Element]>\)> Function to be evaluated in browser context
|
- `pageFunction` <[function]\([Array]<[Element]>\)> Function to be evaluated in browser context
|
||||||
|
|
@ -2536,23 +2553,6 @@ const feedHandle = await page.$('.feed');
|
||||||
expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
expect(await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))).toEqual(['Hello!', 'Hi!']);
|
||||||
```
|
```
|
||||||
|
|
||||||
#### elementHandle.$eval(selector, pageFunction[, arg])
|
|
||||||
- `selector` <[string]> A selector to query page for
|
|
||||||
- `pageFunction` <[function]\([Element]\)> Function to be evaluated in browser context
|
|
||||||
- `arg` <[Serializable]|[JSHandle]> Optional argument to pass to `pageFunction`
|
|
||||||
- returns: <[Promise]<[Serializable]>> Promise which resolves to the return value of `pageFunction`
|
|
||||||
|
|
||||||
This method runs `document.querySelector` within the element and passes it as the first argument to `pageFunction`. If there's no element matching `selector`, the method throws an error.
|
|
||||||
|
|
||||||
If `pageFunction` returns a [Promise], then `frame.$eval` would wait for the promise to resolve and return its value.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
```js
|
|
||||||
const tweetHandle = await page.$('.tweet');
|
|
||||||
expect(await tweetHandle.$eval('.like', node => node.innerText)).toBe('100');
|
|
||||||
expect(await tweetHandle.$eval('.retweets', node => node.innerText)).toBe('10');
|
|
||||||
```
|
|
||||||
|
|
||||||
#### elementHandle.boundingBox()
|
#### elementHandle.boundingBox()
|
||||||
- returns: <[Promise]<?[Object]>>
|
- returns: <[Promise]<?[Object]>>
|
||||||
- x <[number]> the x coordinate of the element in pixels.
|
- x <[number]> the x coordinate of the element in pixels.
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ Documentation.Class = class {
|
||||||
continue;
|
continue;
|
||||||
if (member1.kind === 'method' && member1.name === 'constructor')
|
if (member1.kind === 'method' && member1.name === 'constructor')
|
||||||
continue;
|
continue;
|
||||||
if (member1.name > member2.name) {
|
if (member1.name.replace(/^\$+/, '$') > member2.name.replace(/^\$+/, '$')) {
|
||||||
let memberName1 = `${this.name}.${member1.name}`;
|
let memberName1 = `${this.name}.${member1.name}`;
|
||||||
if (member1.kind === 'method')
|
if (member1.kind === 'method')
|
||||||
memberName1 += '()';
|
memberName1 += '()';
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue