sendKeys not working in Selenium Webdriver

+2 votes

I was trying to send keys to a text box and send a tab key both at the same time to check for the availabilty of the username

Below you can find the code:

 driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys("UserName");
 driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys(Keys.TAB);

Its not working.

Mar 30, 2018 in Selenium by Perry
• 17,100 points
30,228 views

4 answers to this question.

0 votes

If u want to use TAB key use this:

Actions a= new Actions(driver);
a.keyDown(Keys.TAB).perform()
answered Mar 30, 2018 by Johnathon
• 9,090 points
I agree with Johnathon, Actions class allows you to perform multiple keyboard actions using a single action object.
0 votes
driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys("Keys.RETURN");
answered Feb 7, 2019 by anonymous
Can you please explain the difference?
0 votes
driver.findElement(By.xpath("//label[text()='User Name:']/following::div/input")).sendKeys("UserName",Keys.TAB);

By using a comma you can send both username and key-stroke at the same time.

answered Feb 7, 2019 by Priyaj
• 58,020 points
0 votes
this work for me

you should update your JRE to version 1.8
answered Aug 27, 2019 by Afif
Thank you Afif for providing this solution.

Related Questions In Selenium

0 votes
1 answer

findElement(By.xpath()) not working using Selenium WebDriver

element = findElement(By.xpath("//*[@test-id='test-username']"); element = findElement(By.xpath("//input[@test-id='test-username']"); (*) - any ...READ MORE

answered Apr 18, 2018 in Selenium by code_ninja
• 6,300 points
9,338 views
0 votes
1 answer

Selenium WebDriver.get(url) not working

It is a Selenium defect. Problem is ...READ MORE

answered Jun 7, 2018 in Selenium by Meci Matt
• 9,460 points
9,194 views
0 votes
2 answers

Check that the element is clickable or not in Selenium WebDriver

Hi , you want to know only is ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
34,248 views
0 votes
1 answer

Send keys not working selenium webdriver python

As you mentioned send_keys("TEST") are not working, there are ...READ MORE

answered Sep 28, 2018 in Selenium by Meci Matt
• 9,460 points
17,829 views
0 votes
2 answers

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,500 points
13,772 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,187 views
0 votes
2 answers

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

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

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
2,937 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,910 points
7,263 views
0 votes
1 answer

Java.lang.CharSequence cannot be resolved error while using sendKeys() using Selenium Webdriver

You could try this, myElement .sendKeys(new String[] { ...READ MORE

answered Apr 4, 2018 in Selenium by Johnathon
• 9,090 points
4,841 views
0 votes
2 answers

Radio button using Selenium WebDriver

You can try following code snippet: WebElement elem ...READ MORE

answered Aug 28, 2019 in Selenium by Abha
• 28,140 points
4,824 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP