I am trying to get timing of a specific network request with Puppteer.
Is there any way to filter requests from Chrome DevTools Protocol in Puppteer, so that responseReceived
will be fired only when this specific network response is received?
My actual code for this task is:
const client = await page.target().createCDPSession();
await client.send('Network.enable');
// this method is deprecated and I don't know if it was the right thing to use ( https://chromedevtools.github.io/devtools-protocol/tot/Network#method-setRequestInterception )
await client.send('Network.setRequestInterception', {
patterns: [
{
urlPattern: 'https://www.example.com/*task=customaction*',
resourceType: 'XHR',
interceptionStage: 'HeadersReceived'
}
]
});
client.on('responseReceived', (requestId, loaderId, timestamp, type, response, frameId) => {
console.log(`Debug data from: ${response.url} (${requestId})`)
console.log('Timing:')
console.log(response.timing)
detach()
})
The documentation suggests to use Fetch as replacement of Network.setRequestInterception
(https://chromedevtools.github.io/devtools-protocol/tot/Fetch), but it looks like that Fetch Domain propose is modify network requests.