.network.captureRequests() Suggest edits
Since: 2.2.0Capture outgoing network calls from the browser.
network.captureRequests()
is only available when using Chrome or Edge drivers.
Usage
.captureNetworkRequests(onRequestCallback)
.network.captureRequests(onRequestCallback)
Example
describe('capture network requests', function() {
it('captures and logs network requests as they occur', function(this: ExtendDescribeThis<{requestCount: number}>) {
this.requestCount = 1;
browser
.network.captureRequests((requestParams) => {
console.log('Request Number:', this.requestCount!++);
console.log('Request URL:', requestParams.request.url);
console.log('Request method:', requestParams.request.method);
console.log('Request headers:', requestParams.request.headers);
})
.navigateTo('https://www.google.com');
});
});
Parameters
Name | Type | description |
---|---|---|
onRequestCallback |
function | Callback function called whenever a new outgoing network request is made. |