In my application i have a text box which when i click brings the date picker to select a date. One way is to select the date from datepicker or u can manually send in the date. But whenever i send in the date it says it is unable to locate the element.
THis is code for sending the date to the text box
driver.findElement(By.xpath(".//*[@id='txtdateFrom']")).sendKeys("03/05/2013");
It throws the following error
org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":".//*[@id='txtdateFrom']"}
Command duration or timeout: 15 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.31.0', revision: '1bd294d', time: '2013-02-27 20:52:59'
System info: os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_17'
Session ID: 3eea4ac2-2b38-4688-9733-8734077f7d3e
Driver info: org.openqa.selenium.firefox.FirefoxDriver
I dont have the privilege to add the screenshot. Please help!!
Please find the HTML below
<input id="txtdateFrom" class="textbox hasDatepicker" type="text" style="color:Gray;" name="txtdateFrom">
Please find the iframe HTMl
<iframe width="100%" scrolling="auto" height="493" frameborder="1" style="vertical-align: top;" allowtransparency="true" id="ContentMain" src="../Report/AuditorAssignmentReportSearch.aspx?Width=100&Height=528"></iframe>
DOM of the text field which when clicked will populate datepicker
attributes
[type="text", style="color:Gray;", 2 more...]
0
type="text"
1
style="color:Gray;"
2
class="textbox hasDatepicker"
3
id="txtdateFrom"
4
name="txtdateFrom"
and this is the attribute of the datepicker once the text field is clicked
attributes
[class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all"]
0
class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all"
Updated DOM
attributes
[onclick="DP_jQuery_1368459704950.datepicker._selectDay('#txtdateFrom',4,2013, this);return false;", class=
" ui-datepicker-today"
]
0
onclick="DP_jQuery_1368459704950.datepicker._selectDay('#txtdateFrom',4,2013, this);return false;"