Calendar text box - same xpath and how to identify element uniquely | Selenium Forum
R
Rajyalakshmi Gubbala Posted on 26/11/2020

hi,

Below are html for 2 elements. I would like to access first calendar text box. when i use xpath=//*[@id='txtfromdate'] then 2 elements getting high lighted. if i use xpath=//*[@id='txtfromdate'][1] again 2 elements are getting high lighted. with xpath //*[@id='txtfromdate'][0] nothing is identidying. Pls suggest

<input _ngcontent-c5="" autocomplete="off" bsdatepicker="" class="form-control custom-Date date-field ng-pristine ng-valid ng-touched" id="txtfromdate" maxlength="10" name="txtfromdate" placeholder="MM/DD/YYYY" type="text" ng-reflect-maxlength="10" ng-reflect-bs-config="[object Object]" ng-reflect-min-date="Mon Nov 26 2018 12:39:12 GMT+0" ng-reflect-max-date="Wed Nov 25 2020 12:39:12 GMT+0" ng-reflect-name="txtfromdate" ng-reflect-model="Wed Nov 25 2020 12:39:12 GMT+0">

<input _ngcontent-c3="" autocomplete="off" bsdatepicker="" class="form-control custom-Date ng-pristine ng-valid ng-touched" id="txtfromdate" maxlength="10" name="txtfromdate" placeholder="MM/DD/YYYY" type="text" ng-reflect-maxlength="10" ng-reflect-bs-config="[object Object]" ng-reflect-min-date="Mon Nov 26 2018 00:00:00 GMT+0" ng-reflect-max-date="Thu Nov 26 2020 12:39:12 GMT+0" ng-reflect-name="txtfromdate">

 

 


A
Ashish Thakur Replied on 28/11/2020

<input _ngcontent-c3 and <input _ngcontent-c5

Both have different tags. You can use //input _ngcontent-c3[@id='txtfromdate']

 


Related Posts