[英]Why can't browser.getRequest get data?
I use wdio intercept service to test the.network interface,This is his official document .我用wdio拦截服务测试.network接口,这是他的官方文档。 I used it completely according to his instructions, but I didn't get the expected results
我完全按照他的说明使用了,但是没有得到预期的效果
this is my test.js这是我的 test.js
it("test a", async () => {
browser.url("https://www.amazon.in/")
let input = await $("#twotabsearchtextbox")
input.setValue("mobile")
await browser.pause(3000)
await browser.expectRequest("GET", "/api/2017/suggestions", "200")
let searchSuggestions = await browser.getRequest(
"GET",
"https://completion.amazon.in/api/2017/suggestions"
)
console.log("Response Headers", searchSuggestions)
expect(searchSuggestions).to.have.length.above(0)
})
when I run it, I got:当我运行它时,我得到:
expected [] to have a length above +0 but got +0
This is my repo for test: https://github.com/Ruobei/wdioTest.git这是我的测试仓库:https://github.com/Ruobei/wdioTest.git
I checked a lot of materials, but I didn't find the reason, nor did I find any other calling methods。If anyone knows how to solve it, it will be appreciated。查了很多资料都没有找到原因,也没有找到其他的调用方法。如果哪位知道如何解决,不胜感激。
Try with 4.2.2 version:尝试使用 4.2.2 版本:
npm install wdio-intercept-service@4.2.2
You need to call the setup function in order to assess request called.您需要调用设置 function 才能评估调用的请求。 Please add browser.setupInterceptor() after the browser.url() command.
请在 browser.url() 命令后添加 browser.setupInterceptor() 。
More details can be found here: https://webdriver.io/docs/wdio-intercept-service/#api可以在这里找到更多详细信息: https://webdriver.io/docs/wdio-intercept-service/#api
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.