Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save maggiesavovska/51eb0f826bec743f83c3cc8b25650dff to your computer and use it in GitHub Desktop.
Save maggiesavovska/51eb0f826bec743f83c3cc8b25650dff to your computer and use it in GitHub Desktop.
Webdriverio compatible in browser patch for keys
// courtesy of Thamu Gurung @thamu_gurung_twitter
browser.execute(() => {
return $(elementSelector).trigger({ type: 'mousedown', which: 39 });
});
/* The Key codes
rightArrow - 39
leftArrow - 37
down - 40
enter - 13
full list of keys and codes : https://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
Note: The most important here is the type of event associated. As I asked my developer and he told me that the event is "mousedown". In some cases this might be "mouseup" or "keydown" . It is always better to have the library of events which your developer is following.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment