Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

+10 votes
2 views
by (900 points)
recategorized by

I want to put value using webdriver,

This is the command I am using

driver.findElement(By.name("name")).sendKeys("daniel");

I want to put tab keys and keys in text box, can someone suggest an easy way to do so ?

closed

5 Answers

+6 votes
by (13.2k points)
selected by
 
Best answer

If you want to send keys to a text box and send tab key both at the same time instead of writing two different statements, use a comma.

driver.findElement(By.name("name")).sendKeys("daniel",Keys.TAB);

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

If you wish to Learn Selenium visit this Selenium Training by Intellipaat.

by (29.8k points)
thanks this works
by (44.3k points)
Using Keys.TAB helped!
by (47.2k points)
Try clicking on the textbox before you send keys. It may be that you need to trigger an event on the field before input and the click will do it hopefully.
by (41.4k points)
Thanks a lot. It worked.
+4 votes
by (62.9k points)

If your application is using frames, you can try as follows:

First, pass driver control to the frame using----

driver.switchTo().frame("passid/name/index/webelement";

After that perform the operation which you want to do on the web element present inside frame say here you want to enter the text "daniel"--

driver.findElement(By.name("name")).sendKeys("daniel");

I hope that helps!

by (19.7k points)
It worked for me! Thanks!
by (33.1k points)
Thanks for this clear explanation!
+4 votes
by (32.3k points)

In order to use TAB keys here, you need to do something like below:

Actions builder = new Actions(driver);

builder.keyDown(Keys.TAB).perform()

by (19.9k points)
It worked for me. Thank you.
+1 vote
by (108k points)

I also had that problem as well before. But then what I did to make it work is:

myInputElm.click();

myInputElm.clear();

myInputElm.sendKeys('myString');

by (29.3k points)
This worked for me.
0 votes
by (106k points)

You can use click() method [ i.e in your case : clear(), click(), sendKeys() ] before sendkeys()and sendkeys will start working:-

driver.findElement(By.name("name")).clear(); driver.findElement(By.name("name")).click(); driver.findElement(By.name("name")).sendKeys("abc");

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...