I've tried this:
browser.actions().keyDown(protractor.Key.ENTER).keyUp(protractor.Key.Enter).perform();
which gives the error:
Error: Not a modifier key
Keyup/Keydown is limited to modifier keys in WebDriver (shift, ctrl, etc). I think you want
browser.actions().sendKeys(protractor.Key.ENTER).perform();
The actions() is not required.
You can do something like:
var input = $('#someInput');
input.sendKeys(protractor.Key.ENTER);
Update: some people have complained that you are not sending the enter to browser. If you want to do this just change your selector:
$('body').sendKeys(protractor.Key.ENTER);
Here is another way of doing this
var enter = browser.actions().sendKeys(protractor.Key.ENTER);
enter.perform();
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