microsoft / WinAppDriver

Windows Application Driver
MIT License
3.68k stars 1.4k forks source link

Sendkeys with a \ is being converted to # #194

Open beatsm opened 7 years ago

beatsm commented 7 years ago

Hi

I have just tried to run the NotepadTest example and found that when sample tries to save the document to %TEMP%\NotepadTestOutputFile.txt what I see happening is %TEMP%#NotepadTestOutputFile.txt which saves to the wrong place and fails the test.

Any advice?

Regards

timotiusmargo commented 7 years ago

Hi @beatsm, This is interesting. Are you running the test on the machine with standard US keyboard layout selected?

beatsm commented 7 years ago

No, UK keyboard layout.

Regards

Get Outlook for Androidhttps://aka.ms/ghei36


From: Timotius Margo notifications@github.com Sent: Thursday, June 1, 2017 7:15:53 PM To: Microsoft/WinAppDriver Cc: beatsm; Mention Subject: Re: [Microsoft/WinAppDriver] Sendkeys with a \ is being converted to # (#194)

Hi @beatsmhttps://github.com/beatsm, This is interesting. Are you running the test on the machine with standard US keyboard layout selected?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/WinAppDriver/issues/194#issuecomment-305575941, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADQA19HHOZHuHG3fRR0s1eHPJ2UamArqks5r_v_ZgaJpZM4Nns1g.

timotiusmargo commented 7 years ago

I see. At the moment WinAppDriver is only supporting a standard US keyboard layout as specified in the Selenium JSON Wire Protocol spec

In your machine with the UK keyboard layout, the backslash code is mapped to a different character that generates the behavior you saw. A workaround is to set the test machine to have the standard US keyboard layout.

beatsm commented 7 years ago

Thanks

I hope this will be fixed in time.

Apparently pressing alt gr + # should send a . I will test and report back.

Regards


From: Timotius Margo notifications@github.com Sent: Thursday, June 1, 2017 8:22:41 PM To: Microsoft/WinAppDriver Cc: beatsm; Mention Subject: Re: [Microsoft/WinAppDriver] Sendkeys with a \ is being converted to # (#194)

I see. At the moment WinAppDriver is only supporting a standard US keyboard layout as specified in the Selenium JSON Wire Protocol spechttps://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidelementidvalue

In your machine with the UK keyboard layout, the backslash code is mapped to a different character that generates the behavior you saw. A workaround is to set the test machine to have the standard US keyboard layout.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Microsoft/WinAppDriver/issues/194#issuecomment-305594343, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADQA12S1jrvRWN25R_CJd0Evck8bB2K4ks5r_w-BgaJpZM4Nns1g.

beatsm commented 7 years ago

Hi,

Unfortunately I have not been able to work and changing the keyboard on the test machine (my own while I am developing) is a pain.

Is it on the road map to fix this as I don't have this problem with Chrome Driver or FireFox driver.

Regards

rajeeshmenoth commented 6 years ago

Hi @timotiusmargo & @beatsm ,

We are also facing the same issue ? Any updates regarding this issue ?

fenchu commented 6 years ago

I'm using norwegian (ÆØÅ), same issue, I can use norwegian in driver calls like .find_element_by_name("Søk") but not in .send_keys(), no issue with other webdrivers.

lysior commented 6 years ago

Workaround: string Backslash = Keys.Alt + Keys.NumberPad9 + Keys.NumberPad2 + Keys.Alt;

Geraldf commented 5 years ago

I guess this is a general issue. I am using a german keyboard, and sending "/n/AFI/DIC Monitor" via send_keys results in "-n-AFI-DIC Monitor" on the screen.

{"text": "/n/AFI/DIC_Monitor", "value": ["/", "n", "/", "A", "F", "I", "/", "D", "I", "C", "_", "M", "o", "n", "i", "t", "o", "r"], "id": "42.10161586", "sessionId": "B4E10E0B-9069-498E-B1BC-FC4EEAB770A4"} HTTP/1.1 200 OK

andrisi commented 4 years ago

@timotiusmargo Seems you changed to using the local keyboard layout, which is worse in some situations. Couldn't you just enter the charachters sent as it is, and not as a virtualised click on the actual phisical button that would have the given char on it if it were a US keyboard? Because now hitting those keys sends weird characters from my own language. Or add a sendString() like call?

sjmelia commented 4 years ago

Hit this problem and sending Alt-92 triggered an autocomplete drop down. (probably something to do with numeric keypad 2 being a down arrow)

Ended up using a forward slash as a workaround.

reinaldo-gomes commented 4 years ago

Will this ever be fixed?

jp833 commented 2 years ago

Workaround: string Backslash = Keys.Alt + Keys.NumberPad9 + Keys.NumberPad2 + Keys.Alt;

How do you actually send the Alt key as pressed? And then probably long press another key like WASSDZ for e.g. for virtual camera navigation in the Android emulator?

I am using this but does not work -->

((AndroidDriver<AndroidElement>)_driver).LongPressKeyCode(AndroidKeyCode.Keycode_ALT_LEFT, AndroidKeyMetastate.Meta_Alt_LEFT_On);
 ((AndroidDriver<AndroidElement>)_driver).PressKeyCode(AndroidKeyCode.Keycode_D);

I also tested on adb but does not seem to work -

adb shell sendevent /dev/input/event1 1 57 1 or adb shell input keyevent KEYCODE_ALT_LEFT (works in chrome text for e.g. not in camera) or adb shell input keyevent --longpress KEYCODE_ALT_LEFT (works in chrome text for e.g. not in camera)

PyNitid commented 2 years ago

My workaround with this problem was to use the clipboard: C# using System.Windows.Forms; using selenium = OpenQA.Selenium;

System.Windows.Forms.Clipboard.SetText(@"a\rebel\string"); var thatTextbox = driver.FindElementByName("ThatTextboxName"); thatTextbox.SendKeys(selenium.Keys.Control + "v");

Plus: Is faster than typing all keys.

bmueller84 commented 2 years ago

My workaround with this problem was to use the clipboard: C# using System.Windows.Forms; using selenium = OpenQA.Selenium;

System.Windows.Forms.Clipboard.SetText(@"a\rebel\string"); var thatTextbox = driver.FindElementByName("ThatTextboxName"); thatTextbox.SendKeys(selenium.Keys.Control + "v");

Plus: Is faster than typing all keys.

This works great, unless you execute the tests on a different machine...

thopiekar commented 1 year ago

Still valid after more than 5 years 😞