New issue
Advanced search Search tips

Issue 825801 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Jul 1
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Selenium webdriver.switchTo().alert() no longer works with chromeDriver 2.36/2.37

Reported by cassiopa...@gmail.com, Mar 26 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

Steps to reproduce the problem:
Alert alert = webdriver.switchTo().alert();
String alertText = alert.getText();
alert.accept();

What is the expected behavior?
The expected behavior is that chromedriver should switch to the alert, get its text and then close the alert using the accept method.

What went wrong?
This was working correctly in version 2.33 of chromedriver.  Recently the chrome browser has updated and version 2.33 of chromedriver no longer worked with chrome, thus forcing an update to a newer chromedriver, but in every case the alert methods are not working properly anymore.  

Did this work before? Yes chromedriver 2.33

Chrome version: 65.0.3325.181  Channel: stable
OS Version: 6.3.9600
Flash Version: 

This is breaking all of our testcases, and we can't rollback to an older version of chrome as it is not possible to deactivate automatic updates.  This is really bad for developers who should have an option to lock chrome to a chromedriver version to guarantee functionality.
 
Labels: Needs-Bisect Needs-Triage-M65
Cc: susan.boorgula@chromium.org
Components: Tests>WebDriver
Labels: TE-NeedsTriageHelp
The issue seems to be out of TE-scope as it is related to Selenium webdriver.switchTo().alert().
Hence, adding label TE-NeedsTriageHelp and requesting someone from Tests>WebDriver team to look into this issue and help in further triaging.

Thanks...
Labels: Triaged-ET
Labels: Needs-Feedback
I was unable to repro this issue. webdriver.switchTo().alert() worked fine with ChromeDriver 2.37 when I tried it.

Please provide code to repro, and provide ChromeDriver verbose log collected when the test failed. Thanks.

Good afternoon, 

You've asked for a verbose log and the code that is causing the problem, please find the log attached and the code below.  An UnexpectedAlert exception is thrown when webdriver.seitchTo().alert() is called which was not the behaviour in previous versions of chromedriver.  Something has truly has changed here as this code has worked since chromedriver version 2.27 and only stopped working with the latest two versions of chromedriver.   

Just so you guys know, I've been able to work around this and was able to get my testcases running again, although I shouldn't have to catch an unexpectedAlertException when switching to an expected alert.  Thanks for your effort!

public boolean isAlertPresent() {
	Log.logInfo(GroupBase.class, "--> isAlertPresent();");
	try {
		webdriver.switchTo().alert();
		return true;
	} catch (NoAlertPresentException e) {
		return false;
	} 
}

chromedriver.log
1.2 MB View Download
Project Member

Comment 6 by sheriffbot@chromium.org, Mar 29 2018

Cc: johnchen@chromium.org
Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Retrifying:  it's an UnhandledAlertException
Status: WontFix (was: Unconfirmed)
Based on chromedriver.log attached to comment #5, all calls to webdriver.switchTo().alert() failed because no alert was displayed yet. E.g., here is the last call:

[1522340714.801][INFO]: COMMAND GetAlertMessage {
}
...
[1522340714.803][INFO]: RESPONSE GetAlertMessage no alert open

The alert appeared later (21.5 seconds later, according to the timestamp):

[1522340736.344][DEBUG]: DEVTOOLS EVENT Page.javascriptDialogOpening {
   "defaultPrompt": "",
   "message": "As alterações não podem ser salvas por causa de erros no controle de dados.\nMessageID: 1897",
   "type": "alert",
   "url": "http://kbrspapl9:7221/CassiopaeBackDAFCFG/faces/jsp/flowToTilesView.jspx?Adf-Window-Id=w2"
}

A FindElement command was in progress at the time. Since no attempt to accept the alert at the time, it failed.

Looks like you need to adjust when your app checks and accepts alerts.

Hi, thanks John for your analysis.  If you like I can attach a short video showing that the alert opens within one second of the execution of the line before it and not 21.5 seconds later as the verbose log says.  With I find interesting is in the java console log snippet below chrome shows that there is an "unexpected alert open" immediately after an "isAlertPresent" call.  Chrome is reporting the error, although I'm handling it in code so that my test cases don't break, honestly there's still something not correct with this.

2018-04-02 16:12:29 INFO  GroupBase:20 - --> selectComboItem("//*[@name='secId:mainBody:CMBCCHSID60513']", ElementType.XPATH, "Não");
2018-04-02 16:12:31 INFO  GroupBase:20 - --> click("//*[@id='secId:s_zl_aab:s_bey_aab']/a", ElementType.XPATH);
2018-04-02 16:12:33 INFO  GroupBase:20 - --> isAlertPresent();
[1522696353.609][SEVERE]: Unable to retrieve document state unexpected alert open
[1522696353.609][SEVERE]: Unable to retrieve document state unexpected alert open
2018-04-02 16:12:35 INFO  GroupBase:20 - --> isAlertPresent();
2018-04-02 16:12:48 INFO  GroupBase:20 - --> waitGeneric(2.0);
2018-04-02 16:12:48 INFO  GroupBase:20 - --> click("//a[@id='s_tu_aa6']", ElementType.XPATH);

Labels: -Needs-Bisect Needs-Feedback
Status: Unconfirmed (was: WontFix)
I guess it's possible that for some reason Chrome didn't notify ChromeDriver about the alert until much later. Would it be possible for you to provide a short repro code for this issue? Thanks.
Hi John,

As you requested please find attached a zip file which has two java files containing the code you requested.  The CommandBase file has the native selenium commands for alerts and the other java file is the actual test case that references the verbose log previously submitted, the error happens after the click in line 148 and before line 150.  I hope this information helps.  
javafiles.zip
3.8 KB Download
Project Member

Comment 12 by sheriffbot@chromium.org, Apr 5 2018

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding the requester to the cc list.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 13 by l...@chromium.org, Apr 5 2018

Components: -Platform>DevTools
Status: WontFix (was: Unconfirmed)
Unfortunately we are unable to find the cause of this issue. Generally it is difficult to track down an issue unless it can be repro'ed on a publicly available web site.

Sign in to add a comment