Ashish-BeJovial
Ashish-BeJovial

Reputation: 1867

How to click on alert box ok button using nightwatch.js

I am working on ui automation testing using nightwatch.js, i am struggling on a point, i want to click on alert box's "OK" button but i am unable to do it because i didn't find anyway to press alert box's "OK" button on browser using nightwatch.js.

is there any way please suggest.

Upvotes: 6

Views: 6724

Answers (1)

Fredrik Schöld
Fredrik Schöld

Reputation: 1658

You can use the Selenium acceptAlert protocol. It can be used like this:

browser
.url(APP_ROOT)
.waitForElementVisible('.classThatOpensAlert', 2000)
.click('.classThatOpensAlert')
.pause(1000)
.acceptAlert()

Upvotes: 11

Related Questions