angular / protractor

E2E test framework for Angular apps
http://www.protractortest.org
MIT License
8.75k stars 2.31k forks source link

sendkeys for Chrome has issues with non-English keyboards #3003

Closed vincentdieltiens closed 8 years ago

vincentdieltiens commented 8 years ago

When I use the sendKeys method to test a homemade hotkey service, Some tests are failing with chrome for some keys like a or q.

The method sendKeys seems to send the wrong keycode :

The keys for which there is a problem seems to be 'querty' and 'azerty'... I provide below a very simple example that fails with chrome (and should not) and passes with firefox.

Note that i'm using a french version of chrome and firefox with an apple azerty keyboard.

Bug report

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['src/listener.e2e.js'],
  baseUrl: 'http://localhost:3000/',
  multiCapabilities: [{
    'browserName': 'chrome'
  }, {
    'browserName': 'firefox'
  }]
};

Thanks, Vincent

tullmann commented 8 years ago

The chromedriver project has had a bunch of weird bugs with keyboards (especially non-US ones). See https://bugs.chromium.org/p/chromedriver/issues/detail?id=627 (and search for sendKeys in their issue tracker). 627 is marked fixed, but there may still be issues.

You can enable chromedriver logger (see http://stackoverflow.com/questions/31662828/how-to-access-chromedriver-logs-for-protractor-test) to get more details about what keycodes are being sent.

vincentdieltiens commented 8 years ago

After enabling chromedriver logger (with the solution (given by jmr) of running chromedriver in a separate process), here are the logs relatives to the key event :

[5.643][INFO]: COMMAND TypeElement {
   "id": "0.9101050850003958-1",
   "value": [ "", "a", "" ]
}
...
[5.677][DEBUG]: DEVTOOLS COMMAND Input.dispatchKeyEvent (id=47) {
   "modifiers": 0,
   "nativeVirtualKeyCode": 81,
   "text": "",
   "type": "rawKeyDown",
   "unmodifiedText": "",
   "windowsVirtualKeyCode": 81
}
[5.678][DEBUG]: DEVTOOLS RESPONSE Input.dispatchKeyEvent (id=47) {

}
[5.678][DEBUG]: DEVTOOLS COMMAND Input.dispatchKeyEvent (id=48) {
   "modifiers": 0,
   "nativeVirtualKeyCode": 0,
   "text": "a",
   "type": "char",
   "unmodifiedText": "a",
   "windowsVirtualKeyCode": 0
}
[5.678][DEBUG]: DEVTOOLS RESPONSE Input.dispatchKeyEvent (id=48) {

}
[5.678][DEBUG]: DEVTOOLS COMMAND Input.dispatchKeyEvent (id=49) {
   "modifiers": 0,
   "nativeVirtualKeyCode": 81,
   "text": "",
   "type": "keyUp",
   "unmodifiedText": "",
   "windowsVirtualKeyCode": 81
}
[5.678][DEBUG]: DEVTOOLS RESPONSE Input.dispatchKeyEvent (id=49) {

}

So, chromedriver seems to get "a" and translate it to the keyCode 81 which is incorrect...

juliemr commented 8 years ago

Pretty sure this is a ChromeDriver issue. I don't see an open issue of theirs for dealing with this, so we should find the minimal test case and create an issue with them.

juliemr commented 8 years ago

I can't reproduce w/o a custom keyboard - @vincentdieltiens could you please open an issue with chromedriver at https://bugs.chromium.org/p/chromedriver/issues/list? Thanks.

juliemr commented 8 years ago

Closing this as stale and not helpful to keep open.