Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, January 23, 2016

sendkeys are not working in Selenium Webdriver

sendkeys are not working in Selenium Webdriver


I am not able to put any value in my application using web driver. My application is using frames. Using following command I am able to clear the value of my textbox driver.findElement(By.name("name")).clear(); But it does not allow to put any value using following command: driver.findElement(By.name("name")).sendKeys("manish");

even though click command works for button on the same page.

Please suggest me what should i do to resolve this issue.

Thanks in advance.

Answer by Robbie Wareham for sendkeys are not working in Selenium Webdriver


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 hopefully the click will do it

Answer by OPY for sendkeys are not working in Selenium Webdriver


Use javascript to click in the field and then use sendkeys() to enter values. I had a similar problem in past with frames. Javascript is the best way .

Answer by Russell Bradley for sendkeys are not working in Selenium Webdriver


Try using Javascript to sendkeys().

WebElement element = driver.findElement(By.name("name"));  JavascriptExecutor executor = (JavascriptExecutor)driver;  executor.executeScript("arguments[0].click();", element);  

More info on Javascript Executor can be found @ JavascriptExecutor - Selenium

Answer by SATYA for sendkeys are not working in Selenium Webdriver


First pass driver control to frame using----

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

After that perform operation which you want to do on webelement present inside frame--

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

Answer by andyssundaypink for sendkeys are not working in Selenium Webdriver


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');  

Answer by Sandy for sendkeys are not working in Selenium Webdriver


Generally I keep a temp variable. This should work.

var name = element(by.id('name'));  name.clear();  name.sendKeys('anything');  

Hope it helps.

Answer by IRSHAD for sendkeys are not working in Selenium Webdriver


I have gone with the same problem where copy paste is also not working for that text box. Below code is working fine for me-

WebDriver driver = new FirefoxDriver();  String mobNo = "99xxxxxxxx";  WebElement mobileElementIrs =   driver.findElement(By.id("mobileNoPrimary"));  mobileElementIrs.click();  mobileElementIrs.clear();  mobileElementIrs.sendKeys(mobNo);  


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.