0

I'm trying to write an exclamation mark in an input but Protractor fails at this operation.

What I'm trying to do :

element(by.id('nom')).sendKeys('abc!');

But I can only see abc in my field.

I've added a listener on keyup events, the browser is receiving from Protractor :

... keys for 'abc'...
KeyCode : 192 - Code : BackQuote - Key : ~
KeyCode : 16  - Code : ShiftLeft - Key : Shift

I kept the window opened (via browser.pause()) and I entered an exclamation mark manually, thus I got :

KeyCode : 192 - Code : BracketRight - Key : !
KeyCode : 16 - Code : ShiftLeft - Key : Shift

I'm using Google Chrome and I have a QWERTZ keyboard.

Does anyone have an idea of why is this happening ?

Thoomas
  • 1,884
  • 1
  • 15
  • 29
  • Take a look at: https://stackoverflow.com/a/43616117/7709399 – M. Hudson Jul 12 '17 at 13:25
  • @M.Hudson I have translated the Java solution of your linl to JavaScript but it's not working. Exclamation mark is still missing. The problem seems to be elsewhere. – Thoomas Jul 12 '17 at 13:40
  • Have you tried escaping the ! like `'abc\!'`? – JeffC Jul 12 '17 at 14:41
  • @JeffC Yes I had. Unfortunately, it was unsuccessful. – Thoomas Jul 12 '17 at 15:04
  • See: [How do I do X?](https://meta.stackoverflow.com/questions/253069/whats-the-appropriate-new-current-close-reason-for-how-do-i-do-x) The expectation on SO is that the user asking a question not only does research to answer their own question but also shares that research, code attempts, and results. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! See also: [ask] – JeffC Jul 12 '17 at 15:07
  • Thanks for the advice, i'll keep it in mind for the next time. As for this question, the other things i've tried are in the question. – Thoomas Jul 12 '17 at 16:23
  • When I switch the keyboard to QWERTY, it's working : `KeyCode : 49 - Code : Digit1 - Key : ! KeyCode : 16 - Code : ShiftLeft - Key : Shift` Seems to be a bug while using QWERTZ keyboard. – Thoomas Jul 17 '17 at 07:00

1 Answers1

0

I've found a "solution" that's working but it's weird at the same time.

Step 1 : QWERTZ keyboard - Exclamation mark is not sent

KeyCode : 192 - Code : Backquote - Key : ~
KeyCode : 16 - Code : ShiftLeft - Key : Shift

Step 2 : QWERTY keyboard (by setting the language at English - USA) - Exclamation mark is sent

KeyCode : 49 - Code : Digit1 - Key : !
KeyCode : 16 - Code : ShiftLeft - Key : Shift

Step 3 : QWERTZ keyboard (default language) with language English - USA as second language - Exclamation mark is sent

KeyCode : 49 - Code : Digit1 - Key : !
KeyCode : 16 - Code : ShiftLeft - Key : Shift

This is a - not so pretty - workaround. If someone has a real and proper solution, I'm listening !

Thoomas
  • 1,884
  • 1
  • 15
  • 29