Open GoogleCodeExporter opened 9 years ago
Thanks for the report.
I could reproduce the issue.
Just curious, do you expect an alert to be triggered by the click which is to
close the second window (a tab in chrome)?
Original comment by st...@chromium.org
on 26 Feb 2014 at 6:22
The problem within chromedriver is:
when a command related to alert is received, chromedriver tries to connect to
the target window.
However, in this case, the target window is closed already.
For some reason, it hangs if chromedriver sends command to devtools.
Original comment by st...@chromium.org
on 26 Feb 2014 at 6:23
The use case for us is that the alert is conditional. In some cases, when
submitting a form on a pop up, the pop up just closes, and sometimes it throws
up an alert and then closes once the alert is cleared. In either case, we need
to at least check to see if its there before moving on, and we usually catch
the NoAlertPresentException and move on. This wasn't easy to minimally
reproduce so its been happening for many weeks now, and we just narrowed it
down.
Without the sleep, its a race condition, depending on whether the code can
check the alert before the browser closes. With the sleep, it forces the bug.
Original comment by edw...@gmail.com
on 26 Feb 2014 at 1:57
For the moment, you may try replacing the sleep with:
driver.getWindowHandles()
If there no alert and the window is closed, the invalid window handle will be
removed from a cache in chromedriver and you will get a "NoSuchWindow" error.
Original comment by st...@chromium.org
on 26 Feb 2014 at 4:16
Original comment by st...@chromium.org
on 26 Feb 2014 at 4:19
Seems to be doing the trick:
if (driver.getWindowHandles().contains(driver.getWindowHandle()))
.. catch (NoSuchWindowException e)
Original comment by edw...@gmail.com
on 26 Feb 2014 at 7:19
The above workaround seems to work well in ChromeDriver. FirefoxDriver however
treats the scenario differently, causing an UnhandledAlertException to be
thrown, and for the alert to be cleared automatically. Beware of this side
effect if you're running tests on both browsers and try to implement this
workaround.
Original comment by edw...@gmail.com
on 28 Feb 2014 at 7:23
An update, it seems that there is still the smallest of race conditions here
which rears its ugly head in various scenarios:
try {
if (driver.getWindowHandles().contains(driver.getWindowHandle()))
{
// Window must be open
// EXCEPT if it closed the millesecond after executing the above statement
// in which case the following alert will freeze for 10 minutes
Alert alert = driver.switchTo().alert();
}
}
catch (Exception e)
{
// no window open
}
Original comment by edw...@gmail.com
on 5 May 2014 at 6:42
Original comment by samu...@chromium.org
on 21 Feb 2015 at 12:18
Original comment by gmanikp...@chromium.org
on 30 Mar 2015 at 11:38
Original comment by samu...@chromium.org
on 2 Apr 2015 at 10:35
Original issue reported on code.google.com by
edw...@gmail.com
on 25 Feb 2014 at 9:55