LoveLovelyJava one
LoveLovelyJava one

Reputation: 353

cannot handle alert message

I am using Java and Selenium to write a test. My Chrome Browser version is 52.0 and my selenium driver is 2.53. I have a button on my target web page that after clicking on that an alert is shown. I always used :

 try{  wait.until(ExpectedConditions.elementToBeClickable(By.xpath("blabla"))).click();
                    Thread.sleep(1000);
                    wait.until(ExpectedConditions.alertIsPresent());
                    driverChrome.switchTo().alert().accept();
   }
    catch(Exception e){
    e.printStackTrace();
    }

to handle the alert, but since this morning, when test clicks on the button the alert pops up but then right after that it throws:

org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status
from unexpected alert open
 (Session info: chrome=52.0.2743.116)
 (Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 33 milliseconds

it doesn't even get to second and third lines !! the error is thrown by the first line

wait.until(ExpectedConditions.elementToBeClickable(By.xpath("blabla"))).click();

Upvotes: 1

Views: 263

Answers (2)

Abir Khan
Abir Khan

Reputation: 119

You are using chromedriver version 2.20.

Here: https://bugs.chromium.org/p/chromedriver/issues/detail?id=1224&colspec=ID%20Status%20Pri%20Owner%20Summary was told that in 2.22 version this issue is fixed.

So, if possible, you can verify if your problem is fixed, by upgrading your chromedriver version to 2.22.

Upvotes: 2

Grasshopper
Grasshopper

Reputation: 9058

I had come across this same thing with Chrome when the button which was being clicked was inside an iframe. Just ran the test in firefox. Refer to these 2 issues logged in chromium bug tracker -

https://bugs.chromium.org/p/chromedriver/issues/detail?id=1362

https://bugs.chromium.org/p/chromedriver/issues/detail?id=1224

     try{ 
 wait.until(ExpectedConditions.elementToBeClickable(By.xpath("blabla"))).click();

       }
        catch(Exception e){
        e.printStackTrace();
        }
    Thread.sleep(1000);
                        wait.until(ExpectedConditions.alertIsPresent());
                        driverChrome.switchTo().alert().accept();

Upvotes: 1

Related Questions