7

What is the difference between return and enter keys in Selenium? This related SO answer and the provided link state that they are different. I also noticed that enter key will send an HTML form while return doesn't when using Firefox 24.2.

Community
  • 1
  • 1
Mikko Koho
  • 754
  • 6
  • 14
  • with all due respect and honesty, it's bad automated test logic to simulate a key press. You should always click the submit button associated with a search field or something of the sort. – ddavison Jan 27 '14 at 15:16
  • The user interface I am testing contains an input field for selecting multiple keywords. When using it normally with a browser, enter key selects a single keyword and adds it to the list of keywords. With Selenium however enter key sends the form and return key selects a single keyword. – Mikko Koho Jan 31 '14 at 12:56
  • You may use ```\n``` rather. – Shub Jul 31 '21 at 15:55

1 Answers1

6

Normally these keys are interchangeable. I believe the original implementation the Keys. Enter was the enter key on the number pad and the Keys.

Return was the one next to the letters. It's also fine to use these keys in Selenium testing, if it matches a user flow or requirement, which is the goal of testing through the UI.

enter image description here

Azametzin
  • 5,223
  • 12
  • 28
  • 46
Willcurles
  • 71
  • 1
  • 3