【问题标题】:Making webdriverio to wait for an element using webdriverio's waitUntil()?使用 webdriverio 的 waitUntil() 让 webdriverio 等待一个元素?
【发布时间】:2018-06-18 19:46:28
【问题描述】:

Hello People 有谁知道如何实现 Webdriverio 的 waitUntil (显式等待) 以查看元素是否存在?

要检查一个元素是否存在,我们有以下内容:

browser.waitForExist(selector, timeout)

根据元素是否存在于 dom 中,超时后将返回 true 或 false。

按照这个逻辑:

browser.waitUntil( function(){
   return browser.waitForExist(selector) == 'true')
},timeout,'element failed to exist')

应该可以吗?

【问题讨论】:

    标签: automated-tests wait webdriver-io


    【解决方案1】:

    我有下面的代码来识别元素是否存在,在 wdio 中使用waitUntil

    browser.waitUntil(function(){
                return browser.elements(NAVIGATION_ICONS).value.length > 0;
            }, 15000, 'The navigation icon are not there');
    

    变量NAVIGATION_ICONS 是一个xpath。

    希望这会有所帮助。

    谢谢, 纳文。

    【讨论】:

      【解决方案2】:

      我会使用isExisting()

      browser.waitUntil( function(){
          return selector.isExisting())
      },timeout,'element failed to exist')
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-11
        相关资源
        最近更新 更多