So I am using the following code:
import { firefox } from 'playwright';
// domain
let domain = 'https://www.reddit.com/'
// create a new page
const page = await browser.newPage();
// set routes
await page.route('**', async route => {
const response = await route.fetch();
await route.fulfill({ response });
});
// go to the domain
await page.goto(domain);
When run it I can see the traffic go trough my route, but after a seomt time as I start to scroll down the reddit page I stop seeing it. I can see traffic comming in on the dev tools, but it does not get intecepted by my route.
I think it might be intercepting all of the traffic only to load the page, but not anyother requests after that. How can I intercept all of the traffic comming from and to the page.
Thank you ^^
I tried other scrollabel web apps such a tiktok with the same results.
I want to be able to route all of the traffic coming from my page.
2
Answers
You need to handle the request event instead of the fetch event:
import { firefox } from ‘playwright’;
Monitoring Network
With playwright, you can monitor all the Requests and Responses on a page: