rshf / chromedriver

Automatically exported from code.google.com/p/chromedriver
2 stars 1 forks source link

Incorrect keys being sent with remote X server. #677

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is especially frustrating when running Selenium tests inside of a Vagrant 
box using X11 forwarding.

Problem
When running ChromeDriver and Chrome against the local x server, sending keys 
works as expected.
When running ChromeDriver and Chrome against XQuartz via X11 forwarding, 
certain keys are incorrectly mapped (e.g. `e` becomes a backspace).

Software
OS X 10.9.1
XQuartz 2.7.5 (xorg-server 1.14.4)
Ubuntu 12.04
ChromeDriver v2.8.244824
Chromium 31.0.1650.63

Setup
ChromeDriver and Chrome are installed on a Ubuntu VM.
XQuartz is installed on the host operating system: OS X.

Findings
Against the local x server, `e` is x key code 26 and maps to keysym 0x65.
Against the remote x server, `e` is x key code 22 and maps to keysym 0x65.
Against the remote x server, ChromeDriver finds that x key code 22 maps to 
virtual key code 8 (`ui::VKEY_BACK`). ChromeDriver then builds an array of 
virtual key codes to dispatch (via Chrome remote debugging).
Chrome receives the list of virtual keys and...

Theories:
Inside Chrome, `ui::VKEY_BACK` is short-circuited and is never translated to 
its x key code equivalent.
Chrome is not respecting the remote x server’s key code mappings.
…

Workaround
The following hack modifies ChromeDriver to send strings instead of key codes. 
This works for our purposes but means that sending non-string keys (e.g. 
backspace, arrows) probably won't work.

Diff: http://pastebin.com/hDRj8Ey2

Original issue reported on code.google.com by JustinVa...@gmail.com on 16 Jan 2014 at 10:20

GoogleCodeExporter commented 9 years ago
Yes, this is a known issue. ChromeDriver2's key code was borrowed directly from 
ChromeDriver v1 and is platform dependent, which can lead to inconsistencies 
when the chromedriver server in running on a different platform than Chrome 
(this configuration is always the case with Android, for example).

Original comment by craigdh@chromium.org on 16 Jan 2014 at 11:02

GoogleCodeExporter commented 9 years ago
Issue 442 has been merged into this issue.

Original comment by craigdh@chromium.org on 12 Feb 2014 at 10:33

GoogleCodeExporter commented 9 years ago

Original comment by st...@chromium.org on 14 Oct 2014 at 4:05

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:19