Playwright: [Feature] Intercept target creation

Created on 25 Feb 2020  路  4Comments  路  Source: microsoft/playwright

Following this issue from puppeteer, https://github.com/puppeteer/puppeteer/issues/3667, I would like to know if there is a way in playwright to intercept the creation of a target.
The use case is, as in the mentioned issue, to instrument a page before its creation and evaluation (with e.g. request interception and script injection).

Most helpful comment

Yes, it is on its way.

All 4 comments

You will be able to set up interception and initial scripts on the browser context. So all the popups and click navigations that open in new pages will share interception, initial scripts and emulation parameters.

Will this work for you?

The browserContext API: https://github.com/microsoft/playwright/blob/master/docs/api.md#class-browsercontext

It's doesn't seem to be implemented yet. But what you are saying @pavelfeldman, is that it will be eventually? Or am I missing it in the API?
I guess that's what aslushnikov presented in the initial issue.
And yes, that would be perfect for our use cases 馃憣

Yes, it is on its way.

We updated the API and moved/copied many methods to the BrowserContext, e.g. browserContext.route() and browserContext.addInitScript(). This should cover "setup the page" scenario and works nicely with popups and link clicks as well as pages created with context.newPage().

New APIs will be included in the next 0.12 release.

Was this page helpful?
0 / 5 - 0 ratings