我希望将所有请求转换为包括cy.intercept()以下json内容的对象:{'method':'____', 'url':'____', 'response_time':'____'}以便可以将它们写入json文件以进行性能分析。
我目前可以显示所有请求方法和 URL,但不能显示它们的响应时间。
当前获取网络请求的代码:
cy.intercept({method:'GET', url:'**'}).as('gets');
cy.intercept({method:'POST', url:'**'}).as('posts');
cy.visit('url');
Run Code Online (Sandbox Code Playgroud)
是否可以迭代这些单独的请求及其响应时间并将它们保存在数组中?
我尝试将返回的值保存intercept()为变量,但它没有显示所有请求或其响应时间。
var gets = cy.intercept({method:'GET', url:'**'}).as('gets');
var posts = cy.intercept({method:'POST', url:'**'}).as('posts');
cy.visit('url');
cy.writefile('file1.json', gets);
cy.writefile('file2.json', posts);
Run Code Online (Sandbox Code Playgroud)
提前致谢。