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 #11469

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!

alaahong commented 1 year ago

https://github.com/SeleniumHQ/selenium/issues/11468 please refer to first ticket.