Selenium SendKeys() with Chromedriver uses Clipboard Content instead of “@” Character in email adress

白昼怎懂夜的黑 提交于 2021-01-20 12:16:52

问题


Im trying to write an email-address into an input field using Selenium and ChromeDriver in C#. Nothing spectacular so far. But in case of strings, containing "@"characters it is sending the content of the clipboard instead of this character.

For example: The Content of the Clipboard ist "####MYCLIPBOARDCONTENT######" Copied by Ctrl+C

Execution of the Lines

         var input = _webDriver.FindElement(By.Id(id));
         input.Clear();
         input.SendKeys("abc@def.test");

Is leading to this in the UI

Can anyone confirm this behaviour? How to deal with it? I don't want to bypass this by some strange hacks.


回答1:


Use action chains to build "AltGr + Q".

var actions = new OpenQA.Selenium.Interactions.Actions(driver);
actions.KeyDown(Keys.Control).KeyDown(Keys.Alt); //press Alt
actions.SendKeys("Q"); //press Q
actions.KeyUp(Keys.Control).KeyUp(Keys.Alt); //Release key
actions.Build().Perform();



回答2:


Actually i don't want to use these hacks for such basic string operations.

But i found the issue by myself now. It was related to my language settings in Windows. I was using 1. EN-US, 2. DE-DE, and 3. EN-HR. I removed the third one. Now it is working as expected.



来源:https://stackoverflow.com/questions/64385485/selenium-sendkeys-with-chromedriver-uses-clipboard-content-instead-of-char

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!