Protractor - UnexpectedAlertOpenError: unexpected alert open

1,216 views
Skip to first unread message

Yanna Kyprianou

unread,
Jul 14, 2014, 11:55:49 AM7/14/14
to ang...@googlegroups.com
Hi all,

I am really struggling with this for a while.

I have an angular app which throws a confirmation window/alert whenever a reload or navigation change happens. (onbeforereload basically)

Problem is, all the existing end to end protractor tests are failing now as each one has a before each get index.html page and is not expecting an alert.

I have tried what many suggested to get the alert and accept with the following:
alertDialog = browser.switchTo().alert();
  alertDialog.accept();

But it doesn't work. I can't get to the window alert because is failing on the the get page.

Whenever I do a  'browser.get('index.html');'
an 'UnexpectedAlertOpenError: unexpected alert open' is thrown


Any help will be much appreciated


Yanna

unread,
Jul 14, 2014, 4:42:14 PM7/14/14
to ang...@googlegroups.com
I found the problem, it was not an alert but a window.

 browser.get('index.html');
        browser.getAllWindowHandles().then(function (handles) {
            browser.switchTo().window(handles[0]);
        });
Reply all
Reply to author
Forward
0 new messages