trusktr
trusktr

Reputation: 45494

How can we pass a reference from Node into a Puppeteer page?

Is there any way to pass a reference to a page in Puppeteer? Or is it limited only to serializable data?

For example, I'm imagining doing page.exposeFunction('require', ...) to begin making my own Electron, but that won't work if we can only return serializable data.

Upvotes: 0

Views: 192

Answers (1)

Grant Miller
Grant Miller

Reputation: 29037

Puppeteer provides an API to control Chromium over the DevTools Protocol, which means that the Page class utilizes the Page Domain from the Chrome DevTools Protocol.

The return values obtained from the Page domain are all serializable.

Therefore, it appears that you are limited only to serializable data.

Upvotes: 1

Related Questions