Intercept target creation
See original GitHub issueIn many ways, users want to intercept targets being created to attach and set them up.
Usecases:
- when popup is getting opened, attach to it and enable request interception
- when a link click opens a new page, set proper device emulation before website is getting loaded
We might be able to do this with CDP using Target.setAutoAttach
and waitForDebugger
option. I’d like this to be scoped to browser context though so that’s there’s a better flexibility.
The API might look like this:
await browserContext.setTargetInterception(true);
browserContext.on('targetcreated', async target => {
if (target.type() !== 'page') {
await target.resumeLoading();
return;
}
const page = await target.page();
await page.setViewport({width: 400, height: 400});
await target.resumeLoading();
});
Issue Analytics
- State:
- Created 5 years ago
- Reactions:63
- Comments:23 (3 by maintainers)
Top Results From Across the Web
Step 4: Setting Up Your Intercept - Qualtrics
Intercepts decide what target your creative should link to, and the conditions under which the creative should appear on your website. You can...
Read more >Puppeteer: How do I intercept requests across multiple "pages"?
One important thing for you to know is that, although a new target will be created, a PDF will be open by the...
Read more >Intercepting requests | Checkly
Request interception enables us to observe which requests and responses are being ... would result in the target website loading without any CSS...
Read more >A Practical Guide to Intercepting Network Requests in Cypress
With our .intercept() we have matched three different requests. To target e.g. only our POST /api/boards request, we'll write our command like this:....
Read more >Puppeteer documentation - DevDocs
Emitted when a new target is created inside the browser context, for example when a new page is ... In order to intercept...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there an ETA on a fix for this? Browsing pages I do not control, I am watching for the
targetcreated
event in order to inspect popups. When a popup occurs, there doesn’t seem to be any way for me to inspect the network requests. On main page, I can add a handler forrequest
andrequestfinished
prior to apage.goto
which means every network request for that page (even the initial one) can be inspected. However, if I attachrequest
orrequestfinished
event handlers on the popup page, it’s already too late; the page has already started loading and the events never fire (maybe I’ll see some if the page takes a long time to load a bunch of resources, but never the initial one).After the fact, I can get the URLs of things that loaded by inspecting the trace file, but it’s difficult to pinpoint only the ones loaded by the popup. In addition, I don’t have access to all the other goodies provided by the Request object (headers, content, etc.).
A fix or any workaround suggestion would be greatly appreciated!
Everyone who’s interested in seeing this fixed: Please star this chromium bug reported by Niek, so the chromium devs know there’s strong interest in getting this resolved - thanks!
https://bugs.chromium.org/p/chromium/issues/detail?id=1070568