Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WebDrivero方法中没有一种是使用Appium和WebDrivero(JavaScript)等待元素显示的_Javascript_Webdriver_Appium_Webdriver Io - Fatal编程技术网

WebDrivero方法中没有一种是使用Appium和WebDrivero(JavaScript)等待元素显示的

WebDrivero方法中没有一种是使用Appium和WebDrivero(JavaScript)等待元素显示的,javascript,webdriver,appium,webdriver-io,Javascript,Webdriver,Appium,Webdriver Io,我正在尝试为本地android应用程序编写一个使用appium服务器的webdriverio JavaScript测试用例 我的测试用例要求我登录应用程序,在登录3-4秒后,我应该单击按钮元素。我尝试了所有WebDrivero API,如waitForDisplayed、isDisplayed,但都不起作用,大多数时候错误消息是: TypeError: client.element(...).waitForDisplayed is not a function at Contex

我正在尝试为本地android应用程序编写一个使用appium服务器的webdriverio JavaScript测试用例

我的测试用例要求我登录应用程序,在登录3-4秒后,我应该单击按钮元素。我尝试了所有WebDrivero API,如waitForDisplayed、isDisplayed,但都不起作用,大多数时候错误消息是:

  TypeError: client.element(...).waitForDisplayed is not a function
      at Context.<anonymous> (test-auto-obi-copy.js:142:14)
      at processImmediate (internal/timers.js:439:21)
      at process.topLevelDomainCallback (domain.js:130:23)
登录测试成功完成,但在按下登录按钮后,我想让我的测试套件休眠,直到下一页加载,为了实现这一点,我试图等待,直到这个特定的配置文件按钮元素变为可用,但似乎无法等待


有人能告诉我在这种情况下该怎么办吗?我怎么等?

WebDrivero在从v4->v5移动时更改了一些函数的名称。waitForDisplayed就是其中之一

WebdriverIO v4->.waitForVisible WebdriverIO v5->.waitForDisplayed 有相当多的函数稍微更改了名称,因此值得一看-此外,v4的文档仍然存在,但搜索起来有点困难-

此外,通过将undefined作为第一个参数传递,您的延迟将只等待默认的500毫秒。你可能会想要这样的东西

.waitForDisplayed5000,对
您正在运行哪个版本的WebDrivero?@Shining WebDrivero:^4.6.1然后重试。改为waitForVisible-waitForDisplayed是V5中的方法名称我现在正在尝试使用v4 waitForVisible,该函数如您所述被识别,它在按下登录后等待,然后显示主页,然而,它抛出了一个错误“无法读取未定义的属性‘选择器’——isVisible.js at isVisible-waitForVisible.js”,你知道什么可能导致它以及如何解决吗?我认为在v4上你必须执行类似于浏览器的操作。单击“android=new UiSelector.resourceIdcom.example.dev:id/nav_graph_profile”,而不是链接-如果您阅读v4文档,您将看到它在结构上与v5有何不同,在v5中,您可以调用选择器上的.click方法。非常感谢您,但是我可以再问一个问题吗?因为我有一个困惑,我现在迁移到API v5,并且我正在使用异步函数访问it2。我每次都创建一个唯一的变量,比如let button1=wait client.$'selector';button1.单击,但是它们没有按顺序执行,例如,在代码中,我将值发送到两个字段并单击按钮,但在填充字段之前单击按钮。我正在等待每个选择器并逐个应用操作,但是webdriver命令的执行顺序与日志中的顺序不一样?这里是完整的it方法,我不确定是否有这个问题-我想这可能与addValue有关,需要花费一些额外的时间来编写内容,但这段时间不计入异步;然而,你可能要自己研究这个问题,也许要为这个问题开始一个新的问题
it("should press the profile button", function () {
    return client
    .element('android=new UiSelector().resourceId("com.example.dev:id/nav_graph_profile")')
    .waitForDisplayed(undefined, true)
    .click('android=new UiSelector().resourceId("com.example.dev:id/nav_graph_profile")')
    .then( function() {
        //whatever
    })
})