WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

SendKeys not always send correct keys (if keyboard differs (Swedish, English))

Open Soloveykos opened this issue 6 years ago • 5 comments

  1. Define the datetime as string: string date = DateTime.Now.ToShortDateString();
  2. sendKeys for some text control: someWindowsElementTextControl.SendKeys(date); Actual result: Depending on windows culture it will send different data, for example: Swedish environment with dateTime format yyyy-mm-dd: 2018+10+09 English environment with dateTime format mm/dd/yyyy: 10/09/2018

Expected result: As far as I understand SendKeys() should send the exact keys which are on the 'string' variable. doesn't matter which culture it is (Swedish or English).

Additional info: If we use ToShortDateString() for both cultures it will work for English and probably other cultures but not for Swedish. So we have a workaround for now: ToShortDateString().Replace("-", string.Empty);

Soloveykos avatar Oct 09 '18 09:10 Soloveykos

Hi @Soloveykos,

This is as expected, currently we only support the US keyboard. We've marked this as a potential future enhancement.

hassanuz avatar Oct 09 '18 22:10 hassanuz

FYI duplicate of/related to https://github.com/Microsoft/WinAppDriver/issues/215

Exoow avatar Sep 03 '19 07:09 Exoow

When it comes to UI testing, relevance of culture environment and keyboard layout are emphasized. Hence, shouldn't this strong restriction be mentioned a bit more prominent - say on the intro page? Not at least this is likely to be a show stopper for many outside US who need to test in their native culture settings and moreover it's harsh to learn about this issue perhaps after investing in convincing decider, introducing developer and creating test suites containing cases that maybe exotic for US but relevant in foreign context. Btw, running the WinAppDriver unit tests suite in non-US environment settings breaks every related test, which appears to be expected after what I've learned here.

ApolloCreek avatar Dec 13 '19 10:12 ApolloCreek

Any other alternative to this sendkeys ? It often fails on azure pipelines agent windows-2019. can we install winappdriver release using commad line so we can install specific version on pipeline agent?

sacerande avatar Jan 29 '22 10:01 sacerande

The problem is that WinAppDriver (actually WebDriver) conflates keys (WM_KEYDOWN) and text (WM_CHAR). We're missing an api to send "untranslated" text to the target process (ie without involving the TranslateMessage win32 API).

tristanlabelle avatar Jul 03 '23 14:07 tristanlabelle