From f49687f747f3467bce2608ea0421eaa099a8081e Mon Sep 17 00:00:00 2001 From: Andrey Lushnikov Date: Thu, 13 Sep 2018 19:25:15 +0100 Subject: [PATCH] docs(api.md): add frame example (#3237) Add an example on how to work with frame's API. Fixes #3232. --- docs/api.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/api.md b/docs/api.md index 844ba41f47a..75ac02504a0 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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]> Promise which resolves to ElementHandle pointing to the frame element.