.network.captureRequests() 建议编辑
自:2.2.0捕获来自浏览器的传出网络调用。
用法
.captureNetworkRequests(onRequestCallback)
.network.captureRequests(onRequestCallback)
示例
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');
});
});
参数
名称 | 类型 | 描述 |
---|---|---|
onRequestCallback |
函数 | 每当发出新的传出网络请求时调用的回调函数。 |