Selenium WebDriver and Alert with Node.js

347 views
Skip to first unread message

Ricardo Peres

unread,
Jun 18, 2016, 10:35:24 PM6/18/16
to Selenium Users
Hi!

I asked this in SO, but got no answers. Retrying here.

Using Selenium WebDriver in a Node.js app, I am trying to handle (ignore) any alerts that may be open in a web page. For that, I add the "unexpectedAlertBehaviour" capability to my driver with the "ignore" value, as per the documentation:


var caps = { browserName: 'chrome', unexpectedAlertBehaviour: 'ignore' };
var driver = new webdriver.Builder()
    .forBrowser('Chrome')
    .withCapabilities(caps)
    .build();


However, when I run my script with a page that displays an alert, I get an exception:

UnexpectedAlertOpenError: unexpected alert open: {Alert text : This is an alert}

How can I overcome this? To be clear, I do not want to automatically accept the alert, just wait for it to be closed.

Thanks!


RP

Ricardo Peres

unread,
Jun 22, 2016, 3:12:37 PM6/22/16
to Selenium Users
Well, thanks a lot... for nothing...

RP
Reply all
Reply to author
Forward
0 new messages