Lỗi accept alert in selenium với trình duyệt id năm 2024

Originally reported on Google Code with ID 3544

org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined Command duration or timeout: 136 milliseconds Build info: version: '2.20.0',
revision: '16008', time: '2012-02-28 15:00:40' System info: os.name: 'Linux', os.arch:
'amd64', os.version: '3.0.0-1-amd64', java.version: '1.6.0_31' Driver info: driver.version:
RemoteWebDriver
org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
Command duration or timeout: 136 milliseconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-28 15:00:40'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.0.0-1-amd64', java.version:
'1.6.0_31'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:170)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:123)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:438)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:442)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteAlert.accept(RemoteWebDriver.java:714)
    at net.elitem.gui.model.base.WebDriverComponent.clickAndAcceptConfirmation(WebDriverComponent.java:158)
What steps will reproduce the problem?
        someElement.click(); // triggers a javascript confirmation dialog
        Alert alert = this.context.switchTo().alert();
        String actualConfirmationText = alert.getText();
        alert.accept();
        assertEquals(expectedConfirmationText, actualConfirmationText);
What is the expected output? 
The confirmation window should be accepted.
What do you see instead?
The test aborts with above exception.
Interestingly, getting the dialog's text works, but accepting it doesn't.
Selenium version: 2.20
OS: Linux amd64
Browser: Firefox
Browser version: 10

Reported by

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

7 on 2012-03-13 09:28:43

The text was updated successfully, but these errors were encountered:

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

Reported by

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

7 on 2012-03-13 09:30:42

This issue was fixed in r16079 and should be fixed for 2.21

Reported by

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

9 on 2012-03-13 21:00:19

  • Status changed:

    Still happening using 2.22.0.

    0

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

Reported by

Still happening using 2.22.0.

1 on 2012-03-17 23:34:06

  • Status changed:

    Still happening using 2.22.0.

    2

Reported by

Still happening using 2.22.0.

3 on 2012-05-10 21:05:15

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

Reported by

Still happening using 2.22.0.

4 on 2012-05-11 17:32:58

Still happening using 2.22.0.

Reported by

Still happening using 2.22.0.

5 on 2012-06-07 19:07:34

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

Reported by

Still happening using 2.22.0.

6 on 2012-06-18 21:23:41

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

Reported by

Still happening using 2.22.0.

6 on 2012-06-18 21:27:13

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

Reported by

Still happening using 2.22.0.

8 on 2012-07-10 22:43:38

Also getting this in 2.24.1.
This throws the same exception (sometimes):
Alert alert = null;
Wait wait = new WebDriverWait(driver, 10, 50);
try {
   alert = wait.until(ExpectedConditions.alertIsPresent());
} catch (TimeoutException ignored) {
}
if (alert != null) {
   alert.accept(); // this line throws the exception
}

Reported by

Still happening using 2.22.0.

9 on 2012-07-20 13:43:16

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

0

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

0 on 2012-07-25 23:11:01

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

1

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

1 on 2012-07-26 14:37:31

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

2

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

2 on 2012-09-11 12:19:41

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

3

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

3 on 2012-09-12 17:10:12

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

4

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

4 on 2013-02-21 13:10:19

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

5

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

5 on 2013-03-06 09:13:23

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

6

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

1 on 2013-03-06 09:31:46

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

7

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

5 on 2013-03-06 12:57:49

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

8

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

5 on 2013-03-11 08:12:48

I want to add that it fails sometimes, not always. So it seems to be some kind of timing
problem. Adding a Thread.sleep() or fluentWait seems to help, but we are not completely
sure.

9

Reported by

I am also seeing this issue with 2.23.1.  In the following code:
} else if (action.equalsIgnoreCase("continue")) {
    driver.switchTo().alert().accept();
        return "pass";
The 'continue' text is successfully detected, but the accept() method is failing with:
Caused by: org.openqa.selenium.WebDriverException: a.document.getElementsByTagName("dialog")[0]
is undefined
So, it appears WebDriver has detected the correct window and can read text.
  • Chris

9 on 2013-05-16 13:35:48

This issue was fixed in r16079 and should be fixed for 2.21

0

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

0 on 2013-05-28 09:33:15

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

1 on 2013-06-15 15:55:26

This issue was fixed in r16079 and should be fixed for 2.21

1

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

2 on 2013-06-21 13:10:13

This issue was fixed in r16079 and should be fixed for 2.21

2

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

3 on 2013-06-29 09:50:44

This issue was fixed in r16079 and should be fixed for 2.21

3

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

4 on 2013-07-18 04:41:10

This issue was fixed in r16079 and should be fixed for 2.21

4

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

5 on 2013-08-12 10:46:11

This issue was fixed in r16079 and should be fixed for 2.21

5

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

6 on 2013-08-29 12:04:39

This issue was fixed in r16079 and should be fixed for 2.21

6

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

7 on 2013-09-05 15:18:53

This issue was fixed in r16079 and should be fixed for 2.21

7

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

8 on 2013-12-18 10:50:30

This issue was fixed in r16079 and should be fixed for 2.21

8

Reported by

I should mention that this is not an issue on Ubuntu 10.04.  We only see this on Windows
7 and it is regular, but not constant.  It is more likely to occur when running many
tests before this one.  When I run this test in isolation on Windows 7, it typically
runs successfully.

9 on 2014-01-24 18:11:28

This issue was fixed in r16079 and should be fixed for 2.21

9

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

0 on 2014-02-10 13:13:30

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

0

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

1 on 2014-06-18 11:36:34

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

1

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

2 on 2014-07-03 14:35:01

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

2

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

3 on 2014-07-11 13:42:28

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

3

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

4 on 2014-07-22 14:58:46

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

4

Reported by

Still happening using 2.22.0.

3 on 2014-07-23 08:25:04

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

5

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

6 on 2014-08-11 15:57:24

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

6

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

7 on 2014-08-27 00:05:23

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

7

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

8 on 2014-09-04 11:17:43

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

8

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

9 on 2014-09-26 01:05:48

I think this is actually a race-condition between our detection logic and the window
painting - can you update as to whether 2.21 fixes this, when it's released?

9

Reported by

I don't think this is a Windows issue only. I am seeing this error on unix (fc13) using
selenium 2.24.1 as well.

7 on 2014-09-26 09:35:09

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

0

Reported by

Also getting this in 2.24.1.
This throws the same exception (sometimes):
Alert alert = null;
Wait wait = new WebDriverWait(driver, 10, 50);
try {
   alert = wait.until(ExpectedConditions.alertIsPresent());
} catch (TimeoutException ignored) {
}
if (alert != null) {
   alert.accept(); // this line throws the exception
}

1 on 2014-10-17 15:50:38


- _Attachment: [issue.py](https://storage.googleapis.com/google-code-attachments/selenium/issue-3544/comment-43/issue.py)_

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

1

Reported by

Still happening using 2.22.0.

3 on 2014-11-05 22:09:05

  • Status changed:

    Still happening using 2.22.0.

    0

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

2

Reported by

Also getting this in 2.24.1.
This throws the same exception (sometimes):
Alert alert = null;
Wait wait = new WebDriverWait(driver, 10, 50);
try {
   alert = wait.until(ExpectedConditions.alertIsPresent());
} catch (TimeoutException ignored) {
}
if (alert != null) {
   alert.accept(); // this line throws the exception
}

4 on 2014-11-13 20:58:14

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

3

Reported by

Also getting this in 2.24.1.
This throws the same exception (sometimes):
Alert alert = null;
Wait wait = new WebDriverWait(driver, 10, 50);
try {
   alert = wait.until(ExpectedConditions.alertIsPresent());
} catch (TimeoutException ignored) {
}
if (alert != null) {
   alert.accept(); // this line throws the exception
}

5 on 2014-11-21 06:13:05

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

4

Reported by

Also getting this in 2.24.1.
This throws the same exception (sometimes):
Alert alert = null;
Wait wait = new WebDriverWait(driver, 10, 50);
try {
   alert = wait.until(ExpectedConditions.alertIsPresent());
} catch (TimeoutException ignored) {
}
if (alert != null) {
   alert.accept(); // this line throws the exception
}

4 on 2015-01-27 16:09:20

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

5

Reported by

Also getting this in 2.24.1.
This throws the same exception (sometimes):
Alert alert = null;
Wait wait = new WebDriverWait(driver, 10, 50);
try {
   alert = wait.until(ExpectedConditions.alertIsPresent());
} catch (TimeoutException ignored) {
}
if (alert != null) {
   alert.accept(); // this line throws the exception
}

7 on 2015-03-17 20:24:34

This is still happening for me with 2.21. For now, my workaround is to sleep a bit before
accepting the alert

6

Reported by

Also getting this in 2.24.1.
This throws the same exception (sometimes):
Alert alert = null;
Wait wait = new WebDriverWait(driver, 10, 50);
try {
   alert = wait.until(ExpectedConditions.alertIsPresent());
} catch (TimeoutException ignored) {
}
if (alert != null) {
   alert.accept(); // this line throws the exception
}

8 on 2015-03-18 07:44:44

Reported by

Also getting this in 2.24.1.
This throws the same exception (sometimes):
Alert alert = null;
Wait wait = new WebDriverWait(driver, 10, 50);
try {
   alert = wait.until(ExpectedConditions.alertIsPresent());
} catch (TimeoutException ignored) {
}
if (alert != null) {
   alert.accept(); // this line throws the exception
}

9 on 2015-09-17 18:15:03

  • Labels added: Restrict-AddIssueComment-Commit