Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Wrong keycode expected when using shift modifier in EventsTest::testKeybordEvents? #36

Open
robertfausk opened this issue Mar 29, 2019 · 4 comments

Comments

@robertfausk
Copy link
Contributor

When I send "r" to the browser then keycode 114 is used but when I send r and modifier shift to browser then keycode 82 is used.
I encounter a problem because test case always expects keycode 114.


Assertion:
$input2->keyPress('r', $modifier);
$this->assertEquals('key pressed:114 / '.$eventProperties, $event->getText());
Provider:
'ctrl' => array('ctrl', '0 / 1 / 0 / 1'),

Pressed r:
image
Pressed shift+r:
image

@aik099
Copy link
Member

aik099 commented Mar 29, 2019

Why test suite doesn't fail currently, when automatic testing is performed on Travis CI?

@robertfausk
Copy link
Contributor Author

This is exactly what I am also wondering about :D

@aik099
Copy link
Member

aik099 commented Mar 30, 2019

If you're using Selenium you can actually run that specific test only and through real time debugging (e.g. xdebug) you can pause exactly at the moment after key is pressed to see what's happening.

The test really should be working as if real user is pressing these keys. It's highly unlikely, that keydown/keypress and similar methods in the driver are working incorrectly for so many years and nobody have noticed anything.

Maybe when you press Shift+r it's detected as 2 key presses Shift and r.

@andrewnicols
Copy link
Contributor

andrewnicols commented Nov 28, 2019

I'm also seeing this with my new W3C Driver. This is definitely a bug in this testsuite.

I suspect that the reason that this has not been picked up earlier is that the Selenium2 Drvier is using Syn.js to call:

syn.trigger({{ELEMENT}}, "keypress", $options);

However, syn.trigger is not a part of the public API for Syn, and it literally takes what you give it. It does not convert take the lowercase r key, and apply the shift modifier to it.

If you try this in a browser, you'll see that shift+r gives you a keycode of 82 and the Shift modifier. The same browser shows "shift+r" as having a keycode of 114 (lowercase r) when run with this testsuite, or even just calling syn.trigger directly.

We should replicate the user-browser behaviour within these tests.

This is a bug both in these tests, and also within the Drivers which consume them.

robertfausk added a commit to robertfausk/mink-panther-driver that referenced this issue Mar 28, 2020
* Adopted base events test cause the base test only checks for last key event. But if we want to test this with webdriver we have to first keyDown all keys one by one and then keyUp them one by one. The keyUp can not be done with both keys at once, so only the last up event gets asserted by base test.
* Use key value "82" instead of "114" for shift+r cause this seems to be the real one.
Also see: minkphp/driver-testsuite#36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants