Webdriverio: How to terminate the modifier keys when KEYS command is used?

Created on 22 Feb 2016  路  2Comments  路  Source: webdriverio/webdriverio

With below code I am getting only Shift + a or Alt + a, whichever is sent first followed by space. I think it is because the modifier keys is still depressed when shift is pressed, how should we terminate the keys?

 browser.url('https://elements.polymer-project.org/bower_components/iron-a11y-keys/demo/index.html')
    .click('x-key-aware')
    .keys('Shift')
    .keys('a')
    .keys('Alt')
    .keys('a')
    .keys('\uE00D')

Most helpful comment

browser.url('https://elements.polymer-project.org/bower_components/iron-a11y-keys/demo/index.html')
    .click('x-key-aware')
    .keys('Shift')
    .keys('a')
    .keys('\uE000') //Sending null character. To complete the shortcut for shift+a
    .keys('Alt')
    .keys('a')
    .keys('\uE000') //Sending null character. To complete the shortcut for Alt+a
    .keys('\uE00D')

All 2 comments

Thanks to @Elusive138 who answered on gitter.

https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidelementidvalue

Modifier keys (Ctrl, Shift, Alt, and Command/Meta) are assumed to be "sticky"; each modifier should be held down (e.g. only a keydown event) until either the modifier is encountered again in the sequence, or the NULL (U+E000) key is encountered.
browser.url('https://elements.polymer-project.org/bower_components/iron-a11y-keys/demo/index.html')
    .click('x-key-aware')
    .keys('Shift')
    .keys('a')
    .keys('\uE000') //Sending null character. To complete the shortcut for shift+a
    .keys('Alt')
    .keys('a')
    .keys('\uE000') //Sending null character. To complete the shortcut for Alt+a
    .keys('\uE00D')

Was this page helpful?
0 / 5 - 0 ratings