I'm using protractor for angular end-to-end aka e2e
testing.
In order to send keys to an element, I use:
element(by.model('myModel')).sendKeys('Test');
How can I send a combination of keys, like Ctrl+A
?
I've searched through protractor source code at github, but haven't found a relevant example.
It's perfectly possible in Linux and Windows but not in OSX
var elm = element(by.model('myModel')); elm.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, "a"));
There is also a non-element variant:
browser.actions().keyDown(protractor.Key.CONTROL).sendKeys('a').perform();
If you use protractor-hotkeys, you can use simple hotkey strings (like those from angular-hotkeys) to trigger them in protractor tests.
So, this would become:
var hotkeys = require('protractor-hotkeys'); hotkeys.trigger('ctrl+a', { targetElement: element(by.model('myModel')) });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With