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,020 points
12,954 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 29, 2018 by Johnathon
• 9,080 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 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 by Priyaj
• 56,900 points
0 votes
this work for me

you should update your JRE to version 1.8

http://learn-automation.com/solution-for-sendkeyscharsequence-in-selenium/
answered Aug 27 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,220 points
1,890 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,420 points
2,161 views
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,420 points
9,506 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,420 points
2,664 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,090 points
725 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,650 points
296 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
982 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,080 points
705 views
0 votes
2 answers

Radio button using Selenium WebDriver

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

answered Aug 28 in Selenium by Abha
• 23,900 points
1,316 views