ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Wait for alert dialog is throwing timeout exception even if there is an existing alert dialog on Chrome Windows7 #899

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

If I run a code that opens an alert dialog on a loop and then it closes it by 
accepting or dismissing. then in the middle of execution it is constantly 
throwing TimeoutException even though the alert dialog is opened and is visible.

Here is a code snippet that reproduce the problem.

 for (int i = 0; i < 20; ++i) {
    WebDriverWait waitForElement = new WebDriverWait(driver, 10);
    waitForElement.until(ExpectedConditions.presenceOfElementLocated(By.id("alertButton")));

    WebElement element = driver.findElement(By.id("alertButton"));
    element.click(); //opens an alert dialog

    WebDriverWait waitForDialog = new WebDriverWait(driver, 20);
    waitForDialog.until(ExpectedConditions.alertIsPresent()); // exception thrown here

    driver.switchTo().alert().accept();
 }

Here is the actual exception.

org.openqa.selenium.TimeoutException: Timed out after 20 seconds waiting for 
alert to be present
Build info: version: '2.42.2', revision: 
'6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: '', ip: '', os.name: 'Windows 7', os.arch: 'amd64', 
os.version: '6.1', java.version: '1.7.0_65'

Selenium version: 2.42.2
OS: Windows 7
Browser: Chrome
Browser version:36

Original issue reported on code.google.com by para.sel...@gmail.com on 19 Aug 2014 at 1:35

GoogleCodeExporter commented 9 years ago
Please provide also a sample page for this sample scenario.

Original comment by barancev on 19 Aug 2014 at 9:05

GoogleCodeExporter commented 9 years ago
I attache a simple html file. 

Original comment by para.sel...@gmail.com on 19 Aug 2014 at 5:54

Attachments:

GoogleCodeExporter commented 9 years ago
What chromedriver version do you use?

I couldn't reproduce the issue with chromedriver 2.10 and chrome 36:

      WebDriver driver = new ChromeDriver();
      driver.get("http://fiddle.jshell.net/barancev/oL0go930/show/light/");

      for (int i = 0; i < 100; ++i) {
        WebDriverWait waitForElement = new WebDriverWait(driver, 10);
        waitForElement.until(ExpectedConditions.presenceOfElementLocated(By.id("alertButton"))).click();;

        WebDriverWait waitForDialog = new WebDriverWait(driver, 20);
        waitForDialog.until(ExpectedConditions.alertIsPresent()); // exception thrown here

        driver.switchTo().alert().accept();
      }

      driver.quit();

Original comment by barancev on 21 Aug 2014 at 8:14

GoogleCodeExporter commented 9 years ago
I am using the same version of chrome driver  2.10
This problem is happening on my machine constantly, but in other machines I can 
not reproduce this issue I tested it on two other machines with same platform, 
although execution is going slower and slower on each iteration.
And as a workaround I am using some additional thing that I can not understand, 
if I run 
((JavascriptExecutor) driver).executeScript("");  
while I waiting an alert dialog, the test will pass without throwing any 
exception, and the execution will be more faster. I tested it by decreasing the 
wait time to 5 seconds and no problem.
So maybe this will give you some idea what is going there. 

 for (int i = 0; i < 100; ++i) {
      ...
      waitForElement.until(ExpectedConditions.presenceOfElementLocated(By.id("alertButton"))).click();

      ((JavascriptExecutor) driver).executeScript("");   

      WebDriverWait waitForDialog = new WebDriverWait(driver, 5);
      ...
 } 

Original comment by para.sel...@gmail.com on 26 Aug 2014 at 8:41

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:41