mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
parent
a582acd682
commit
f49687f747
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user