Chris Hansen
Chris Hansen

Reputation: 8635

wait for element present without error

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.

Upvotes: 1

Views: 853

Answers (1)

Bao Tran
Bao Tran

Reputation: 626

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.

Upvotes: 2

Related Questions