简体   繁体   English

为什么browser.getRequest获取不到数据?

[英]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.

相关问题 为什么不能从 Selenium 的链接中获取所有数据 - why can't get all data from link from Selenium 为什么Selenium需要打开浏览器即不能最小化浏览器? - Why does Selenium need a browser to be open i.e. the browser can't be minimised? Selenoid:为什么我不能运行特定的浏览器版本? - Selenoid: why can't I run specific browser version? 为什么不能用 selenium 获取 hkdrates 表? - Why can't get the hkdrates table with selenium? 为什么我的[TestMethods]无法引用我在[测试初始化​​]中制作的浏览器? - Why can't my [TestMethods] reference the browser I made in [test initialize]? Selenium remotewebdriver启动浏览器二进制文件但没有WebDriver-如何清理浏览器进程 - Selenium remotewebdriver starts browser binary but doesn't get a webdriver - how can I clean up the browser process Browser.get() 方法无法获取 URL。 此代码是 Python 代码的一部分 - Browser.get() method can't get the URL. This code is a part of a Python code 无法打开基于Firefox的浏览器 - Can't open Firefox-based Browser 不能将 Selenium 与公司修改的浏览器一起使用 - Can't use Selenium with the Company Modified Browser 使用 selenium 从浏览器获取数据 - get data from browser using selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM