Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I am new to Selenium. I just want to send keys to a username text box and send a tab key both at a time so that the text box can check for the availability of username.

Here is 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);

But this one is not working.

1 Answer

0 votes
by (62.9k points)
edited by

If you want to use TAB you need to do something like below:

Actions builder = new Actions(driver); builder.keyDown(Keys.TAB).perform()

I hope this helps!

Browse Categories

...