Readonly Text boxes in webdriver

2,235 views
Skip to first unread message

Sandy

unread,
Aug 27, 2012, 4:34:38 AM8/27/12
to seleniu...@googlegroups.com
Dear  Friends,

        While making test data for test cases using selenium webdriver, I have a calender control, which fills date data in a text box, which is readonly for a user.
Only after selecting calender control/date/month/year and time value got filled in text box. I directly want to fill the text (not by using the calender control) using

((JavascriptExecutor)Driver).executeScript("arguments[0].value=arguments[1]", Driver.findElement(By.xpath("//input[contains(@id,'startDateTimeInputDate')]")), "2012-05-28 05:33:00");


But this is not doing anything.. Can some one have any other approach for filling data in readonly fields, ( Because web driver behaves similar to the human, so as human can not write in text boxes same is the case with web driver.) I also had tried this in past but was not successful...

Driver.findElement(By.xpath("//input[contains(@id,'startDateTimeInputDate')]")).sendKeys("2012-05-28 05:33:00");


Thanks in advance...


Regards

Sandeep Thakur
   

Sandy

unread,
Aug 28, 2012, 3:51:54 AM8/28/12
to seleniu...@googlegroups.com
Problem resolved....

The below given command was correct I was doing a mistake that I was trying to clear the content of the readonly box before the below statement .... :) which was the culprit...

((JavascriptExecutor)Driver).executeScript("arguments[0].value=arguments[1]", Driver.findElement(By.xpath("//input[contains(@id,'startDateTimeInputDate')]")), "2012-05-28 05:33:00"); 

Anyhow same can also be achieved by using the web driver backed selenium....

Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
selenium.type("//input[contains(@id,'startDateTimeInputDate')]", "2011-05-22 05:33:00"); 

I hope this will be helpful to others also in future...

Regards
Sandeep
Reply all
Reply to author
Forward
0 new messages