Reputation: 3878
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()
Upvotes: 2
Views: 615
Reputation: 13782
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(); }
Upvotes: 1