SeleniumHQ / selenium

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

[🐛 Bug]: Handle non-US keyboards in sendKeys in Chrome with Remote Debugging #14551

Open MilanKarapandzic opened 1 month ago

MilanKarapandzic commented 1 month ago

What happened?

Hi!

When I want to use .net Selenium package with a Chrome browser with Remote Debugging (started with the option "--remote-debugging-port"), I have problems with some special characters in SendKeys, if I select non-US keyboard. If the browser is started without the remote debugging option, this is working properly, probably due to the fix in the issue https://github.com/SeleniumHQ/selenium/issues/4253.

An example of the issue:

How can we reproduce the issue?

// start the broswer using the command:
//   ".\chrome.exe --remote-debugging-port=9222 --user-data-dir=<profile>"

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

var optionsChrome = new ChromeOptions
{
    DebuggerAddress = "localhost:9222"
};

var webDriver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), optionsChrome, TimeSpan.FromSeconds(10));

webDriver.Manage().Window.Maximize();
webDriver.Navigate().GoToUrl("https://myqabee.com/");
webDriver.FindElement(By.Id("myModalBtn1")).Click();

Thread.Sleep(1000);

webDriver.FindElement(By.Id("fName")).SendKeys("This is @ test");

Thread.Sleep(2000);

webDriver.FindElement(By.XPath("//*[@id=\"myModal\"]/div/div/div[1]/button")).Click();

Relevant log output

...

[1727866733.105][INFO]: [a3cb224619f1e2a7b97367d35d21d5e3] COMMAND TypeElement {
   "id": "f.D8A1AC54E6E7245E34557A1233F9275B.d.E15662094B285962CB1C5B36ECA55C61.e.1261",
   "text": "This is @ test",
   "value": [ "T", "h", "i", "s", " ", "i", "s", " ", "@", " ", "t", "e", "s", "t" ]
}

...

[1727866733.123][DEBUG]: DevTools WebSocket Command: Input.dispatchKeyEvent (id=142) (session_id=7C7686B1E50BF4F9108F2C203D5890E2) D8A1AC54E6E7245E34557A1233F9275B {
   "code": "KeyV",
   "commands": [ "Paste" ],
   "key": "v",
   "modifiers": 3,
   "text": "@",
   "type": "rawKeyDown",
   "unmodifiedText": "v",
   "windowsVirtualKeyCode": 86
}
[1727866733.123][DEBUG]: DevTools WebSocket Command: Input.dispatchKeyEvent (id=143) (session_id=7C7686B1E50BF4F9108F2C203D5890E2) D8A1AC54E6E7245E34557A1233F9275B {
   "code": "KeyV",
   "commands": [ "Paste" ],
   "key": "v",
   "modifiers": 3,
   "text": "@",
   "type": "char",
   "unmodifiedText": "v",
   "windowsVirtualKeyCode": 86
}
[1727866733.123][DEBUG]: DevTools WebSocket Command: Input.dispatchKeyEvent (id=144) (session_id=7C7686B1E50BF4F9108F2C203D5890E2) D8A1AC54E6E7245E34557A1233F9275B {
   "code": "KeyV",
   "commands": [ "Paste" ],
   "key": "v",
   "modifiers": 3,
   "text": "@",
   "type": "keyUp",
   "unmodifiedText": "v",
   "windowsVirtualKeyCode": 86
}

Operating System

Windows 11

Selenium version

.net Selenium.WebDriver 4.25.0

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

Google Chrome 129.0.6668.71

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

ChromeDriver 129.0.6668.70

Are you using Selenium Grid?

No

github-actions[bot] commented 1 month ago

@MilanKarapandzic, 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!