foxr
foxr copied to clipboard
implement events
https://github.com/GoogleChrome/puppeteer/blob/v1.6.2/docs/api.md#class-page
page.on('close') and so on.
So...
There is no (simple) way to have a non-blocking events like in Puppeteer:
const page = await browser.newPage()
page.on('console', msg => console.log(msg.text()));
await page.evaluate(async () => { console.log('hi') })
await browser.close()
because Marionette uses a classic asynchronous transport model: sends message with an ID and then asynchronously gets a response using the same ID.
Options I see:
- Something like blocking
getLogin Nightwatch with an initial global hook:
const page = await browser.newPage()
await page.evaluate(async () => { console.log('hi') })
console.log(await page.getLog())
await browser.close()
- Introduce a second layer of real-time communications between page and Foxr using an injected WebSocket. Not sure if Puppeteer has been using the same or there is a direct way to do that in Chrome Debugging Protocol.