I came across this solution to my initial problem, which was to simulate an ENTER or RETURN key press using Selenium WebDriver.
However, in my code, I strictly want to use only one of the two WebElement.sendKeys(Keys.ENTER);
vs WebElement.sendKeys(Keys.RETURN);
.
What is the best practice when doing the same, since there seems to be divided opinion about using enter or return, since both work MOST of the time? In what scenarios would one or the other not work, and is there one which would ALWAYS work?
As a performancewise I do not get any change on both of these,
But yes I know one difference on them
Keys.Enter
is used to enter key on the number pad
while
Keys.Return
is used to one next to the letters
Generally I have preferred Keys.Enter
as sometimes in some browser Keys.Return
is not worked for me