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
• 12,890 points
5,523 views

3 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,458 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
153 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,146 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,470 points
2,152 views
0 votes
1 answer
0 votes
1 answer

How to scroll the Page up or down in Selenium WebDriver? (using java)

Its pretty simple. Check out the below ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,050 points
5,191 views
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
164 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
155 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
553 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.