In Selenium, I click a button and an alert box appears, and I tried to accept the alert box, but it gives me an error.
element.click();
driver.switchTo().alert().accept();
It's very inconsistent... Sometimes the tests pass, sometimes it gives me the error...
The error looks like:
NoSuchAlertError: no alert open
(Session info: chrome=34.0.1847.131)
(Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.9.2 x86_64)
at new bot.Error (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/atoms/error.js:109:18)
at Object.bot.response.checkResponse (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/atoms/response.js:106:9)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/webdriver.js:276:20
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:375:7)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1465:10
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:375:7)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:375:7)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:678:49
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/http/http.js:96:5
at IncomingMessage.<anonymous> (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/http/index.js:114:7)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
==== async task ====
WebDriver.switchTo().alert()
at webdriver.WebDriver.schedule (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/webdriver.js:267:15)
at webdriver.WebDriver.TargetLocator.alert (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/webdriver.js:1429:27)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/test/bandbooking/form.js:87:39
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:375:7)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:375:7)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at then (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:478:7)
at Object.webdriver.promise.asap (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:723:11)
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1609:25)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at then (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:478:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:369:18)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at then (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:478:7)
at Object.webdriver.promise.asap (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:723:11)
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1609:25)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at then (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:478:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:369:18)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1465:10
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at then (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:478:7)
at Object.webdriver.promise.asap (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:723:11)
at newFrame.then.e (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1614:25)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:375:7)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at webdriver.promise.ControlFlow.resolveFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1519:9)
at webdriver.promise.ControlFlow.getNextTask_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1488:12)
at webdriver.promise.ControlFlow.runEventLoop_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1446:59)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
==== async task ====
at Context.<anonymous> (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/testing/index.js:126:14)
at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:196:15)
at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:374:10)
at /usr/local/lib/node_modules/mocha/lib/runner.js:452:12
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:299:14)
at /usr/local/lib/node_modules/mocha/lib/runner.js:309:7
at next (/usr/local/lib/node_modules/mocha/lib/runner.js:247:23)
at /usr/local/lib/node_modules/mocha/lib/runner.js:271:7
at done (/usr/local/lib/node_modules/mocha/lib/runnable.js:185:5)
at /usr/local/lib/node_modules/mocha/lib/runnable.js:199:9
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/testing/index.js:92:5
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:375:7)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1465:10
at Object.webdriver.promise.asap (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:732:5)
at newFrame.then.e (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1614:25)
at /Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/goog/base.js:1178:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1598:20)
at notify (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:428:12)
at notifyAll (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:397:7)
at resolve (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:375:7)
at fulfill (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:493:5)
at webdriver.promise.ControlFlow.resolveFrame_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1519:9)
at webdriver.promise.ControlFlow.getNextTask_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1488:12)
at webdriver.promise.ControlFlow.runEventLoop_ (/Users/kstrife/Desktop/experiments/seleniumNode/selenium-webdriver/lib/webdriver/promise.js:1446:59)
at wrapper [as _onTimeout] (timers.js:252:14)
at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)