When i have a reference to a Puppeteers ElemntHandle is there a method to get the Page instance were this element belongs to (or was previously retrieved from via $(selector)
)? something similar to elementHandle.contentFrame()
If you do not mind using undocumented properties:
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const [page] = await browser.pages();
const handle = await page.$('body');
console.log(handle.executionContext().frame()._frameManager._page === page);
} catch (err) { console.error(err); } finally { await browser.close(); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.