docs(api.md): add frame example (#3237)

Add an example on how to work with frame's API.

Fixes #3232.
This commit is contained in:
Andrey Lushnikov 2018-09-13 19:25:15 +01:00 committed by GitHub
parent a582acd682
commit f49687f747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2180,6 +2180,14 @@ puppeteer.launch().then(async browser => {
});
```
An example of getting text from an iframe element:
```js
const frame = page.frames().find(frame => frame.name() === 'myframe');
const text = await frame.$eval('.selector', element => element.textContent);
console.log(text);
```
#### frame.$(selector)
- `selector` <[string]> A [selector] to query frame for
- returns: <[Promise]<?[ElementHandle]>> Promise which resolves to ElementHandle pointing to the frame element.