I'm using ChromeDriver to test a webpage. Usually, it works without a problem but sometimes I get this exception:
org.openqa.selenium.UnhandledAlertException: unexpected alert open
(Session info: chrome=38.0.2125.111)
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 16 milliseconds: null
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'
System info: host: 'Casper-PC', ip: '10.0.0.4', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_25'
Driver info: org.openqa.selenium.chrome.ChromeDriver
So, to get rid of this, I handled this alert:
Alert alt = driver.switchTo().alert();
alt.accept();
But this does not work and now i get no element exception: org.openqa.selenium.NoAlertPresentException
Below is the screenshot:-
Can someone suggest the solution? Because I do not receive this exception always. And when it occurs then the test fails.