foxr icon indicating copy to clipboard operation
foxr copied to clipboard

implement events

Open deepsweet opened this issue 7 years ago • 1 comments

https://github.com/GoogleChrome/puppeteer/blob/v1.6.2/docs/api.md#class-page

page.on('close') and so on.

deepsweet avatar Aug 09 '18 08:08 deepsweet

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:

  1. Something like blocking getLog in 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()
  1. 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.

deepsweet avatar Aug 13 '18 20:08 deepsweet