New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Driver left in inconsistent state after error: The alert disappeared before it could be closed #1297
Comments
I agree that this behavior should ideally be consistent, but it is easily worked around as is, and I disagree with you on the desired behavior. Firefox is the only browser that closes the alert when throwing the exception (and apparently even that is platform specific). The w3c spec for this does not explicitly define a behavior for this situation, but as I read "When a user prompt appears, it is the task of the subsequent command to handle it," it implies that closing the alert should not be automatic when an exception is thrown.
Because this behavior isn't explicitly defined by JSON Wire Protocol, and we are moving to Marionette anyway (which also does not dismiss the alert), this is either 'not a bug' or 'won't-fix.' |
Hi, Thanks for looking into it and providing your feedback. Can you please clarify what will be the workaround for this issue? I tried handling alert by myself by overriding using capabilities but it does not work. Like you can see in code, it throws 'so such alert' exception when trying to handle alert and 'unexpected alert exception' when trying to execute other commands. This is turning out to be a big blocker for us. Any help will be highly appreciated. |
You should close the alert yourself when the popup shows up. I don't know if Java has a special condition for waiting for an alert, or the syntax for accepting an alert, but in Ruby:
|
Thanks for reviewing it again. One more thing that i think you missed while reviewing is that this testcase works perfectly fine when executed on MAC OS, but fails everytime executed on CentOS 6.5 We have huge number of tests, and we run selenium on our cloud running CentOS 6.5, and this issue is causing lots of noise in our tests. With your permission, can I please re-open the bug for your kind consideration? |
Another thing is that i am unable to close the alert once this condition is reached. Basically I can't run any command after this without failure. Any command to handle alert results in no alert exception, and any other command results in unhandled alert exception. |
I get it. You have to close the alert, but the alert has gone away so you can't so the test has to die. Like I mentioned in my email reply, try polling the alert to be present by rescuing the not-present exceptions, then explicitly close it. If that doesn't work, I'll reopen it and we can figure out if there is something else going on. |
We have to let the session die not just the test. One session i used fir a If you look at the test script, you will understand more clearly. Look at AlertTestForCentOS.java On Saturday, November 21, 2015, Titus notifications@github.com wrote:
Rajat Jindal | Gurgaon | http://quicksilver1183.com | |
I'm saying re-write your code so you are never in the condition when you need to access an alert that has gone away. |
what I am trying to convey here is that, no matter how I try to handle this, it gets into this situation very often, and once in this situation, no matter what command I run, it always fails until I kill my complete test suite. and when I say we have huge number of tests, we have about 18k tests, and a testsuite can have about 1000 testcases (worstcase, average tests are about 300 per test suite) and when this error occur all the remaining tests in same test suites can't run anymore. Writing code to poll for alert after each click will increase the execution time by days (not hours) for us. Traditionally we have used WebDriverBackedSelenium approach by overriding javascript alert and confirmation methods but that has its own set of issues, and therefore we are trying to move to native way of handling alerts and confirmations. I will request you to give this issue little time, and I am sure with your expertise, you can quickly figure out whats going on once you run test scripts. Can I please re-open this bug? Thanks |
Your requirements confuse me. |
We were using overrides of alert and confirmation method to handle alerts, ( to give you more context we migrated these tests from selenium RC to Here are the steps we generally do as part of testing our webapp:
So we dont want to check for alert after every command but handle it using If we have to reset alert after receiving this exception explicitly, i am I am happy to chat with you in selenium irc channel if you still have On Saturday, November 21, 2015, Titus notifications@github.com wrote:
Rajat Jindal | Gurgaon | http://quicksilver1183.com | |
Good on you for doing the migration to WebDriver; having done that before I know it is no small feat. The bottom line for this project, though, is that w3c standard says that you must deal with an alert after one opens. As such, there is no requirement on our part to ensure that your test can recover from the exception that comes from not doing what the spec requires. That being said, I recognize in the scenario you described how the non-determinant nature of that process can make real-world testing of it challenging. I would approach these with a helper method that submits the form, checks for an alert and fails the test if found, and moves on if not. Another thing I've done is to restart the browser after any test that could result in an Alert issue. You can also try running with Chrome. I know these aren't ideal solutions, but I still don't think this is an actual bug. I'll ping the other devs on IRC on Monday when more of them are around, in case they disagree with me. :) |
I didn't realize this was a capability option that Firefox supports. You can set unexpectedAlertBehaviour to "accept", "dismiss" or "ignore". Default behavior is to accept, so if you set it to ignore, then you can rescue the exception and then explicitly send the command to accept/dismiss it, and you shouldn't lose your session. Let me know if that works. |
Thanks for checking this out Titus. Appreciate that. However setting unexpectedAlertBehaviour to ignore does not fix the problem. |
Are you saying Firefox is not recognizing unexpectedAlertBehaviour? |
I agree. and thats something I am trying to convey by mentioning again and again that this issue happens on Firefox but only on CentOS platform. Same piece of code works on MAC. :) Let me know how can I help you (ofcourse to help me), to understand and debug this problem? Thanks |
Hi Titus could you please re-open this issue for further consideration. Thanks |
I don't use Java to run your tests. Can you give me the output from each of these tests with ignore turned off & on? Are you running on centos with xvfb? via Jenkins? |
Issue seen on Platform: CentOS 6.5/Firefox 42.0/Selenium 2.48.2
works fine on: Mac OS/Firefox 42.0/Selenium 2.48.2
Test scripts/html can be found here: https://gist.github.com/rajatjindal83/4331f7fc6d5d9b819c3d
Steps to reproduce:
Please let me know if I can provide more information.
Thanks
Rajat Jindal
The text was updated successfully, but these errors were encountered: