Back
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 ?
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.
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"--
I hope that helps!
In order to use TAB keys here, you need to do something like below:
Actions builder = new Actions(driver);builder.keyDown(Keys.TAB).perform()
Actions builder = new Actions(driver);
builder.keyDown(Keys.TAB).perform()
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');
myInputElm.click();
myInputElm.clear();
myInputElm.sendKeys('myString');
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");
31k questions
32.8k answers
501 comments
693 users