wait for element present without error

好久不见. 提交于 2019-12-11 06:17:17

问题


is there a way to call waitForElementPresent in nightwatch without erroring out if the element is not there?

Right now, if you pass in false as the third parameter, you still see an error. Ideally, I would like a function that waits for an element, and returns if it didn't find the element.


回答1:


you can do it :

  Browser.waitForElementPresent('@element',3000,false, function(result){
    If(result.value === true){
    // test if element present
    }else{
    // test if element not present
    }
  })

Since the day one, i did this and the problem with this code is nightwatch would count a failed test as a passed test,as you see above code handle both result value.

So i recommend let the nightwatch return error itself, write difference function for difference value.



来源:https://stackoverflow.com/questions/39051214/wait-for-element-present-without-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!