WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

SendKeys() using unknown keyboard configuration instead of local (azerty vs qwerty-like)

Open Exoow opened this issue 7 years ago • 27 comments

I'm using Appium to automate our new app. My first attempts is as simple as the code below. Here we use the AZERTY keyboard configuration.

However, the text entered in the app is with a QWERTY-like configuration, so "aaa" comes out as "qqq". My "regular" Selenium tests never had this issue. However, trying out all the keys gave me some weird results. For example, I get the colon character twice from different keys, but no dot character... So it's not a correct QWERTY either.

DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", "Company.NewApp_nhrabtd3q6ea2!App");
appCapabilities.SetCapability("platformName", "Windows");
appCapabilities.SetCapability("deviceName", "WindowsPC");

MobileFormsSession = new WindowsDriver<WindowsElement>(new Uri(WindowsApplicationDriverUrl), appCapabilities);

MobileFormsSession.FindElementByAccessibilityId("username").SendKeys("aaa");

Exoow avatar Jun 30 '17 08:06 Exoow

currently only US keyboard layout is supported. We do understand what is going on here and would like to fix this.

yodurr avatar Jul 10 '17 20:07 yodurr

@yodurr Agreed but isn't it partially a bug also (because I never get the dot, but colon twice)?

For those interested: the work-around is to copy text to the Windows clipboard and paste it. This keeps the text as passed in the test methods.

Exoow avatar Jul 11 '17 05:07 Exoow

The copy past workaround won't work if driving an app remotely. Can you fix this bug. It's annoying to switch keyboard during development one for testing and one for developing. It's hard to test mutlilanguages application

CyrilJ avatar Oct 20 '17 06:10 CyrilJ

I have the same issue. I am in Spain and when I run my program in Appium, if I do not change the keyboard language configuration to EN-US, my tests do not work.

Please, it would be interesting to fix this issue.

manudh4 avatar May 18 '18 11:05 manudh4

Can you update the keyboard language programmatically?

Exoow avatar May 18 '18 12:05 Exoow

@Exoow Yes. I have not program it yet, but I know that exists ways to change this by code. Anyway, if this were implemented in the code, it would be a great improvement. I think when you write a text in a SendKeys function. the text should be sent as you wrote, not depending about the language configuration, right?

manudh4 avatar May 18 '18 16:05 manudh4

Hello, I have exactly the same error do you have a solution? Thanks

olivierhelin avatar Mar 06 '19 16:03 olivierhelin

i have the same error do you have a solution plz?

ridarifi avatar May 23 '19 10:05 ridarifi

if any one can help me plz

ridarifi avatar May 23 '19 10:05 ridarifi

any updates???

sasha943 avatar Jun 20 '19 12:06 sasha943

Two years later, still can't write a test properly... 👎

Exoow avatar Sep 03 '19 07:09 Exoow

I have a workaround on Windows 10 for this problem, but I hope this will be solved soon:

You can set a keyboard shortcut for the keyboard layout in Windows Settings -> Time & language -> Region & language -> Additional date, time, & regional settings -> Change input methods -> Advanced settings -> Change language bar hot keys.

I set US keyboard layout to ctrl+0 and my local keyboard layout to ctrl+1 and in my testcode I am using the shortcuts to switch the keyboard layout ...

// switch to US keyboard layout Actions switchKeyboardLayoutActions = new Actions(session); switchKeyboardLayoutActions.SendKeys(Keys.Control + "0" + Keys.Control); switchKeyboardLayoutActions.Build(); switchKeyboardLayoutActions.Perform();

// your send keys actions ...

// switch back keyboard layout switchKeyboardLayoutActions = new Actions(session); switchKeyboardLayoutActions.SendKeys(Keys.Control + "1" + Keys.Control); switchKeyboardLayoutActions.Build(); switchKeyboardLayoutActions.Perform();

bhaas avatar Sep 05 '19 08:09 bhaas

can we get an update on this issue? it makes no sense to me that SendKeys does NOT send the keys you want, depending on your locale, and that something like that gets labeled as an enhancement, not a bug personaly, i was happy to learn that Katalon(which i use for automation testing) now supports WinAppDriver, but if i have to change my locale every time i want to test a windows application, then i won't be automating those anytime soon please let us either specify a locale for the WinAppDriver or get the current locale when starting the driver

IzunaNeko avatar Dec 19 '19 12:12 IzunaNeko

Bump! This needs to be fixed...

xiler8 avatar Jan 16 '20 17:01 xiler8

We have VMs that we setup for automated tests, so a workaround that configures windows manually is not an option. Is there a way to switch the keyboard layout programmatically? Please fix this annoying bug.

SystemCheater avatar Feb 19 '20 12:02 SystemCheater

Other layouts than US keyboard would be very handy in cases for non-english apps. It cannot be that you have to change the keyboard layout on the test machines to achieve this.

akaer avatar Feb 21 '20 15:02 akaer

I'm having this issue also with - becoming + because I'm on a swedish keyboard layout. This should probably be prioritized since it seems to break alot of peoples tests.

jotunskij avatar Feb 24 '20 09:02 jotunskij

This is a royal pain in the a**!

Weiman74 avatar Mar 13 '20 13:03 Weiman74

Same here. Gotta resort to windows API's ugly and fragile workarounds to change the keyboard.

Also, ActivateKeyboardLayout doesn't seem to work for me.

reinaldo-gomes avatar Apr 18 '20 15:04 reinaldo-gomes

Same here, would love to get this fixed, any update?

benabbon avatar Feb 09 '21 17:02 benabbon

Any update on this??? Same issue here with a machine using German layout.

Also, let me just comment that allowing different keyboard distributions does make a lot of sense in UI tests... For example, we have had weird bugs regarding decimal numbers being rendered in the UI, since in Germany they use ',' as decimal separator, whereas in other countries '.' is used

taquion87 avatar Feb 23 '21 04:02 taquion87

That is really a pity. I have the same issue. I would be very happy if you could solve the problem. Thank you very much in advance.

FynnNikolaus avatar May 10 '21 12:05 FynnNikolaus

It boggles the mind that a product is released as production ready with a bug like this, which ties the tests written to the exact keyboard layout that the person who wrote the tests used. @yodurr any news on this?

runemoennike avatar May 21 '21 08:05 runemoennike

Hey, It's been 6 years, is there any quick fix for that issue ?

3rdCore avatar Jun 07 '23 20:06 3rdCore

I too have just run into this issue. I am using the WinAppDriver to control a open file dialog as part of some automated tests. I am trying to set the file path but because I have a English UK keyboard instead of C:\somefolder I get C:#somefolder which obviously is not much use. To arrive here after searching for a solution I am appaled discover this is such an old issue with no response. Shameful!

PeeDeeWhite avatar Aug 08 '23 20:08 PeeDeeWhite

Would be nice to finally solve this issue.

gkovacic avatar Oct 30 '23 19:10 gkovacic

Would be nice if Microsoft didn't recommend a testing framework, then abandon it while promissing that it really isn't abandoned.

runemoennike avatar Oct 31 '23 09:10 runemoennike