Typing the Enter/Return key in Selenium

automated-tests, automation, enter, keypress, selenium

Solution

import org.openqa.selenium.Keys

WebElement.sendKeys(Keys.RETURN);

The `import` statement is for Java. For other languages, it is maybe different. For example, in Python it is `from selenium.webdriver.common.keys import Keys`

Problem

I'm looking for a quick way to type the Enter or Return key in Selenium. Unfortunately, the form I'm trying to test (not my own code, so I can't modify) doesn't have a Submit button. When working with it manually, I just type Enter or Return. How can I do that with the Selenium `type` command as there is no button to click?

Original source

Related problems