How to make protractor press the enter key?

Related searches

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();

Sending Keystrokes to Protractor � ng-book.com – blog, sendKeys(protractor.Key.ENTER); newName.errorMessage. How do you know the test isn't just closing out very quickly after the enter key is sent? to the enter key (focus changes), however, when sending the key press to� 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);

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);

Unable to send the ENTER key command to input fields � Issue , By using this we can simulate Enter keyboard in protractor and we can achieve the keys events Duration: 6:32 Posted: Aug 4, 2019 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:

Here is another way of doing this

var enter = browser.actions().sendKeys(protractor.Key.ENTER);
enter.perform();

Protractor Tutorial 43 | Key Press Events, When there are no more keys to type, all depressed modifier keys are released ( with accompanying keyup events). If this element is a file input ( <input type="file" > )� browser .actions() .sendKeys(protractor.Key.ESCAPE) .perform(); I hope this would work for you. Since the sendKeys and Key is implemented using Keyboard class, the key values will differ for the OS May be. The links below will give the name of the keys you have to give for the sendKeys:

From the docs here...

http://appfigures.github.io/webdriver-js-api-reference/symbols/webdriver.WebElement.html#sendKeys

var myInput = element(by.model('myModel.inputName'));
myInput.sendKeys(value, protractor.Key.ENTER);

Also other examples from the docs linked above.

myInput.sendKeys("text was",
                 protractor.Key.CONTROL, "a", protractor.Key.NULL,
                 "now text is");
// Alternatively:
myInput.sendKeys("text was",
                 protractor.Key.chord(protractor.Key.CONTROL, "a"),
                 "now text is");

Protractor, There are a variety of protractor.Keys you can use: ENTER, SHIFT, TAB and so on.. Learn Protractor in a few hours with our online course. Protractor is a one of the best ways to ensure your app is working correctly because you can write code that acts like a real user.

this will work fine try it

browser.actions().sendKeys(protractor.Key.ENTER).perform();

Trigger a Button Click on Enter. Press the "Enter" key inside the input field to trigger the button: Button. Example // Get the input field

Protractors are a tool used in mathematics to measure angles in degrees. You might need a protractor to work on homework or make construction plans, so learning how to make your own can come in handy. You can make a protractor by printing from a template or folding a square of paper to always have one on hand.

Keys.Enter will simulate the enter key in the keyboard. Keys.Tab also we can simulate. Same way we can perform almost all the actions on the keyboard using protractor.

keyDown can only work for modifier keys, such as Alt, SHIFT, CONTROL. To make protractor press the DELETE key, you can use senKeys like this: browser.actions().sendKeys(protractor.Key.DELETE).perform();

Comments
  • Have you tried ptor.actions().sendKeys(protractor.Key.ENTER)?
  • what is ptor here?
  • His ptor is browser -- browser.actions().sendKeys( protractor.Key.ENTER ).perform();
  • Thank you! A follow up question if I may. Before this was answered I tried: ptor.findElement(protractor.By.model("historyItem")).sendKeys("test5\n"); which actually works. Although I'm sure this isn't the canonical way of doing it; is this actually doing what I think it is?
  • Looks like it would type test5 in the field, then send a newline, which potentially would be like pressing the enter key
  • I'm getting this error with the previous answer Cannot read property 'ENTER' of undefined... Weird thing is it does click the enter key
  • ptor stands for browser - browser.actions().sendKeys(protractor.Key.ENTER).perform();
  • can we press character and Numbers keys using this?
  • @inolasco -- :-1: this answer does not answer the question, as the questioner does not have input: he is sending the key-press to the browser not an element.
  • @LeeGee with .sendKeys() there is no need to call the perform.
  • Awesome! I was looking for a way to test shortcut and you make my day :-)
  • This is the only one that worked for me. Thanks a lot!