sandeep kumar sandeep kumar - 6 months ago 20
Java Question

Unable to locate an element of date picker

I am unable to locate an element of date picker. I tried CssSelector and xpath and everything. Below is the code i tried.

Code :

WebElement dateWidget = driver.findElement(By.xpath(".//*[@id='dp1469511990123']"));
List<WebElement> columns=dateWidget.findElements(By.tagName("td"));

for (WebElement cell: columns)
if (cell.getText().equals("21"))

Here is HTML code.


<input id="dp1469511990123" class="ng-pristine ng-untouched ng-valid >hasDatepicker ng-not-empty" type="text" ng-disabled="input.p1Edit==0" ng->model="vendor.companyStartedDate" ui-date="comp_st_date" disabled="disabled"/>

Here is the Error:

org.openqa.selenium.NoSuchElementException: Unable to locate element: >{"method":"xpath","selector":".//*[@id='dp1469511990123']"}
Command duration or timeout: 10.07 seconds
For documentation on this error, please visit: >
Build info: version: '2.53.0', revision: >'35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host: 'user-PC', ip: '', 'Windows 7', >os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_51'
Driver info: org.openqa.selenium.firefox.FirefoxDriver


The id value looks dynamically generated, I would use an ng-model instead:


Count improved readability as a bonus.

And, see if you need to wait until the presence of the element.