diff --git a/docs/api.md b/docs/api.md index c68583ba..3ed8bca7 100644 --- a/docs/api.md +++ b/docs/api.md @@ -316,8 +316,12 @@ Emitted when a [response] is received. - `pageFunction` <[function]\([Element]\)> Function to be evaluated with first element matching `selector` - `...args` <...[string]> Arguments to pass to `pageFunction` - returns: <[Promise]<[Object]>> Promise which resolves to function return value. +Example: +```js +const outerhtml = await page.$('#box', e => e.outerHTML); +``` -Shortcut for [page.mainFrame().$(selector, pageFunction, ...args)](#pageselector-fun-args). +Shortcut for [page.mainFrame().$(selector, pageFunction, ...args)](#frameselector-pagefunction-args). #### page.$$(selector, pageFunction, ...args) @@ -326,15 +330,22 @@ Shortcut for [page.mainFrame().$(selector, pageFunction, ...args)](#pageselector - `pageFunction` <[function]\([Element]\)> Function to be evaluted for every element matching `selector`. - `...args` <...[string]> Arguments to pass to `pageFunction` - returns: <[Promise]<[Array]<[Object]>>> Promise which resolves to array of function return values. +Example: +```js +const headings = await page.$$('h1,h2,h3,h4', el => el.textContent); +for (const heading of headings) console.log(heading); +``` -Shortcut for [page.mainFrame().$$(selector, pageFunction, ...args)](#pageselector-fun-args). +Shortcut for [page.mainFrame().$$(selector, pageFunction, ...args)](#frameselector-pagefunction-args-1). #### page.addScriptTag(url) - `url` <[string]> Url of a script to be added - returns: <[Promise]> Promise which resolves as the script gets added and loads. + +Adds a `