Is there a way for page.waitForFunction() to return a value from evaluated script?
OR there is another way to use that functionality on another function?
I want to take a screenshot on a lazyloaded site and I need some info sent from parsed script on page. THANK YOU!
Yep, there is a way via the JSHandle.
const playwright = require("playwright");
(async () => {
const browser = await playwright.webkit.launch();
const page = await browser.newPage();
await page.evaluate(() => document.write(`
<div id="foo">bar</div>
`))
const handle = await page.waitForFunction(() => {
return document.getElementById("foo").textContent
})
const value = await handle.jsonValue()
console.log(value)
})();
Or interactive: https://try.playwright.tech/?s=oyh6u
@mxschmitt thank you! it works
Most helpful comment
Yep, there is a way via the JSHandle.
Or interactive: https://try.playwright.tech/?s=oyh6u