How to specify "ENTER" button functionality in Selenium WebDriver code?

0 votes
I'm figuring out a way to hit the "Enter" key in Selenium. Unfortunately the form I'm trying to test doesn't have a Submit button. Neither can I modify it since it is not my own code.

When working with it manually, I hit the "ENTER" button via keyboard. I need to know how to do that with the Selenium typecommand as there is no button to click.
Mar 23, 2018 in Selenium by Shubham
• 13,190 points
6,377 views

3 answers to this question.

0 votes

I'm assuming your writing the code in Java, so you can use the below code to find the element and then click on it:

driver.findElement(By.id("Value")).sendKeys(Keys.ENTER); 

or

driver.findElement(By.id("Value")).sendKeys(Keys.RETURN); 

For this to work, you should also import the "org.openqa.selenium.Keys" package.

answered Mar 23, 2018 by nsv999
• 5,050 points
+1 vote
using OpenQA.Selenium.Interactions;

Actions builder = new Actions(driver);        
builder.SendKeys(Keys.Enter);
answered Feb 12 by anonymous
0 votes

using c#

IwebElement yourLastTextBox = driver.FindElement(By.<search Context>("element locator"));

YourLastTextBox.SendKeys(Keys.ENTER);
answered Mar 15 by Vivek Sharma
What would be the command if I'm using Python?

Related Questions In Selenium

0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
1,616 views
0 votes
1 answer

Can anyone help me that how to run Selenium WebDriver test cases in Chrome?

Download the executable driver from: ChromeDriver Download Before ...READ MORE

answered Mar 29, 2018 in Selenium by nsv999
• 5,050 points
178 views
0 votes
1 answer

How to perform mouse hovering in Selenium WebDriver (Java)?

You many not actually be able to ...READ MORE

answered Apr 3, 2018 in Selenium by nsv999
• 5,050 points

edited Apr 4, 2018 by nsv999 2,342 views
0 votes
1 answer

How to use Actions class in Selenium Webdriver?

In seleniun webdriver it is not mandatory ...READ MORE

answered Apr 4, 2018 in Selenium by Damon Salvatore
• 5,490 points
2,271 views
0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
259 views
0 votes
1 answer
0 votes
1 answer

What is the role of TestNG & JUnit frameworks in Selenium?

Well TestNG and JUnit are test frameworks ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,590 points
192 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
628 views