SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.63k stars 8.18k forks source link

[🐛 Bug]: Alert sendkeys doesn't work in Chrome Prompt #11468

Closed alaahong closed 1 year ago

alaahong commented 1 year ago

What happened?

Just find out the alert sendkeys doesn't work in latest Selenium + Chrome. Both failed in js trigger promot and document sample page https://www.selenium.dev/documentation/webdriver/interactions/alerts/#prompt

Same code can be working in Firefox, but failed in Chrome and Edge.

Previously alert.sendkeys should work for a long time, just raise here to seek any same issue from others.

Thanks.

How can we reproduce the issue?

@Test
  void alertTest(){
    driver.get("https://www.bing.com");
    ((JavascriptExecutor)driver).executeScript("window.prompt('prompt sample')");
    Alert alert =  new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.alertIsPresent());
    alert.sendKeys("sendKeys");
  }

Relevant log output

[1671681207.231][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=24) (session_id=0743D1C9D535379B14E548D258B8E370) 84BE3CA77CC8DCF6A4F86B0F63FCA89E {
   "awaitPromise": true,
   "expression": "(function() { // Copyright 2012 The Chromium Authors\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum for WebDriver status codes....",
   "returnByValue": true
}
[1671681207.236][DEBUG]: DevTools WebSocket Event: Page.javascriptDialogOpening (session_id=0743D1C9D535379B14E548D258B8E370) 84BE3CA77CC8DCF6A4F86B0F63FCA89E {
   "defaultPrompt": "",
   "hasBrowserHandler": true,
   "message": "prompt sample",
   "type": "prompt",
   "url": "https://www.bing.com/"
}
[1671681207.236][DEBUG]: DevTools WebSocket Command: Inspector.enable (id=25) (session_id=0743D1C9D535379B14E548D258B8E370) 84BE3CA77CC8DCF6A4F86B0F63FCA89E {
   "purpose": "detect if alert blocked any cmds"
}
[1671681207.239][DEBUG]: DevTools WebSocket Response: Inspector.enable (id=25) (session_id=0743D1C9D535379B14E548D258B8E370) 84BE3CA77CC8DCF6A4F86B0F63FCA89E {
}
[1671681207.239][INFO]: Waiting for pending navigations...
[1671681207.239][INFO]: Done waiting for pending navigations. Status: unexpected alert open: {Alert text : prompt sample}
[1671681207.239][INFO]: [6503da3be6d0ebc29b128c323379bc00] RESPONSE ExecuteScript
[1671681207.271][INFO]: [6503da3be6d0ebc29b128c323379bc00] COMMAND GetAlertMessage {
}
[1671681207.271][INFO]: Waiting for pending navigations...
[1671681207.271][INFO]: Done waiting for pending navigations. Status: unexpected alert open: {Alert text : prompt sample}
[1671681207.271][INFO]: [6503da3be6d0ebc29b128c323379bc00] RESPONSE GetAlertMessage "prompt sample"
[1671681207.278][INFO]: [6503da3be6d0ebc29b128c323379bc00] COMMAND SetAlertPrompt {
   "text": "sendKeys",
   "value": [ "s", "e", "n", "d", "K", "e", "y", "s" ]
}
[1671681207.278][INFO]: Waiting for pending navigations...
[1671681207.278][INFO]: Done waiting for pending navigations. Status: unexpected alert open: {Alert text : prompt sample}
[1671681207.278][INFO]: [6503da3be6d0ebc29b128c323379bc00] RESPONSE SetAlertPrompt

Operating System

Windows 11

Selenium version

Java 4.7.2

What are the browser(s) and version(s) where you see this issue?

Chrome 108

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 108.0.5359.71

Are you using Selenium Grid?

NA

github-actions[bot] commented 1 year ago

@alaahong, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

pujagani commented 1 year ago

Is this a duplicate of https://github.com/SeleniumHQ/selenium/issues/11469? Can you please check and just keep one of them open please? Thank you!

alaahong commented 1 year ago

Is this a duplicate of #11469? Can you please check and just keep one of them open please? Thank you!

Sorry for duplicated issue, just close last one. Thanks.

diemol commented 1 year ago

So it works in Chrome 107 but not in Chrome 108? Or is it ChromeDriver 107 vs 108?

alaahong commented 1 year ago

On my personal laptop, Chrome 108 + ChromeDriver 108 , alert.sendKeys does not work; On my company laptop Chrome 107 + ChromeDriver 107, alert.sendKeys does not work too.

Caused by chrome will update as latest version, so didn't try more versions. as you mentioned 107, is there any specific background on the version?

diemol commented 1 year ago

It was just an assumption, I understood that it started failing after upgrading. But if it works on Firefox, it might be a Chromium issue.

alaahong commented 1 year ago

Understood, so just raise here to seek if any other met.

Try to add trace log level, it will record info as "unexpected alert open" while switchTo alert. can't find out similar issue on Chromium part. As this is a foundation function, looks odd, actually it works last month till this morning my colleague told me that won't work any more... But I still can't find out root cause.

diemol commented 1 year ago

No more users have chimed in. Probably it is something isolated or an issue related to Chromium based browsers. I will close this and leave some links below in case you want to report it over there.

github-actions[bot] commented 1 year ago

Hi, @alaahong. This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team. Feel free to comment the issues that you raise back in this issue. Thank you.