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 29, 2018 in Selenium by Perry
• 17,090 points

4 answers to this question.

0 votes

If u want to use TAB key use this:

Actions a= new Actions(driver);
answered Mar 29, 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
• 57,550 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,230 points
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
0 votes
1 answer

Check that the element is clickable or not in Selenium WebDriver

Use Selenium Waits: WebDriverWait ...READ MORE

answered Jun 12, 2018 in Selenium by Meci Matt
• 9,460 points
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
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,510 points
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,710 points
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,890 points
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
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
• 27,930 points