Space instead enter

I try to simulate pressing key ENTER. But when I try to do it I have the same result like I pressed SPACE. And I don't understand why it happens. My code:

field.clear().click().sendKeys("Hello");
browser.actions().sendKeys(protractor.Key.ENTER).perform();

I tryed:

field.clear().click().sendKeys("Hello"+"\n");
field.sendKeys("Hello",protractor.Key.ENTER).perform();

But I always have the same result. Then I do it manually it works.

Upvotes: 1

Views: 34

Answers (1)

alecxe
alecxe

Reputation: 473853

Try using RETURN instead:

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

A new-line character can also be an option here:

field.clear().click().sendKeys("Hello" + "\n");

Upvotes: 3

Related Questions