Я выбираю дату из календаря в двух местах на той же странице, но идентификатор календаря динамичен и не может выбрать статическое значение предложения, пожалуйста, как использовать в selenium webdriverpick Calender с динамическим идентификатором, как писать код для статического
<p-calendar id="effectiveFromDate" class="ng-touched ng-dirty ng-valid" inputstyleclass="form-control" name="effectiveFromDate" placeholder="MM/DD/YYYY" required="">
<!--template bindings={}-->
<span class="ui-calendar">
<input id="dp1479794880786" class="form-control hasDatepicker ui-inputtext ui-widget ui-state-default ui-corner-all ui-state-hover" placeholder="MM/DD/YYYY" readonly="" type="text"/>
<!--template bindings={}-->
</span>
<p-calendar id="effectiveToDate" class="ng-pristine ng-valid ng-touched" inputstyleclass="form-control" name="effectiveToDate" placeholder="MM/DD/YYYY">
<!--template bindings={}-->
<span class="ui-calendar">
<input id="dp1479794880787" class="form-control hasDatepicker ui-inputtext ui-widget ui-state-default ui-corner-all ui-state-hover" placeholder="MM/DD/YYYY" readonly="" type="text"/>
<!--template bindings={}-->
</span>
Я использую следующий код, но не в состоянии использовать в одной и той же странице
driver.findElement(By.className("ui-calendar")).click();
<p-accordiontab id="invOverviewTab" header="Invoice Overview" styleclass="margin-b-10">
<div class="ui-accordion-header ui-state-default ui-corner-all ui-state-active">
<div class="ui-accordion-content-wrapper" style="">
<div class="ui-accordion-content ui-widget-content">
<div class="col-md-6 col-sm-6 col-xs-12 margin-t-10 margin-b-10">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="item form-group">
<div class="item form-group invoice-config marginB">
<div class="form-group">
<label for="effectiveFromDate">
<p-calendar id="effectiveFromDate" class="ng-touched ng-dirty ng-valid" inputstyleclass="form-control" name="effectiveFromDate" placeholder="MM/DD/YYYY" required="">
<!--template bindings={}-->
<span class="ui-calendar">
<input id="dp1479805294453" class="form-control hasDatepicker ui-inputtext ui-widget ui-state-default ui-corner-all ui-state-hover" placeholder="MM/DD/YYYY" readonly="" type="text"/>
<!--template bindings={}-->
</span>
<!--template bindings={}-->
</p-calendar>
<p class="text-danger" hidden="">Effective From Date is required</p>
</div>
<!--template bindings={}-->
<div class="form-group">
</div>
<div class="col-md-6 col-sm-6 col-xs-12 margin-t-10 margin-b-10">
<div class="col-md-12 col-sm-12 col-xs-12 form-group text-right">
</div>
</div>
</p-accordiontab>
<p-accordiontab id="invOverviewTab" header="Invoice Overview" styleclass="margin-b-10">
<div class="ui-accordion-header ui-state-default ui-corner-all ui-state-active">
<div class="ui-accordion-content-wrapper" style="">
<div class="ui-accordion-content ui-widget-content">
<div class="col-md-6 col-sm-6 col-xs-12 margin-t-10 margin-b-10">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="item form-group">
<div class="item form-group invoice-config marginB">
<div class="form-group">
<label for="effectiveFromDate">
<p-calendar id="effectiveFromDate" class="ng-touched ng-dirty ng-valid" inputstyleclass="form-control" name="effectiveFromDate" placeholder="MM/DD/YYYY" required="">
<!--template bindings={}-->
<span class="ui-calendar">
<input id="dp1479805294453" class="form-control hasDatepicker ui-inputtext ui-widget ui-state-default ui-corner-all ui-state-hover" placeholder="MM/DD/YYYY" readonly="" type="text"/>
<!--template bindings={}-->
</span>
<!--template bindings={}-->
</p-calendar>
<p class="text-danger" hidden="">Effective From Date is required</p>
</div>
<!--template bindings={}-->
<div class="form-group">
</div>
<div class="col-md-6 col-sm-6 col-xs-12 margin-t-10 margin-b-10">
<div class="col-md-12 col-sm-12 col-xs-12 form-group text-right">
</div>
</div>
</p-accordiontab>
<p-accordion id="accMenu" class="custom-theme-accordion">
<div class="ui-accordion ui-widget ui-helper-reset">
<p-accordiontab id="billClientTab" header="Bill To Client Information">
<div class="row">
<p-accordiontab id="invOverviewTab" header="Invoice Overview" styleclass="margin-b-10">
<div class="ui-accordion-header ui-state-default ui-corner-all ui-state-active">
<div class="ui-accordion-content-wrapper" style="">
<div class="ui-accordion-content ui-widget-content">
<div class="col-md-6 col-sm-6 col-xs-12 margin-t-10 margin-b-10">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="form-group">
<div class="item form-group">
<div class="item form-group invoice-config marginB">
<div class="form-group">
<!--template bindings={}-->
<div class="form-group">
<label for="effectiveToDate">Effective To Date</label>
<p-calendar id="effectiveToDate" class="ng-untouched ng-pristine ng-valid" inputstyleclass="form-control" name="effectiveToDate" placeholder="MM/DD/YYYY">
<!--template bindings={}-->
<span class="ui-calendar">
<input id="dp1479805294454" class="form-control hasDatepicker ui-inputtext ui-widget ui-state-default ui-corner-all ui-state-hover" placeholder="MM/DD/YYYY" readonly="" type="text"/>
<!--template bindings={}-->
</span>
<!--template bindings={}-->
</p-calendar>
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12 margin-t-10 margin-b-10">
<div class="col-md-12 col-sm-12 col-xs-12 form-group text-right">
</div>
</div>
</p-accordiontab>
Где заканчивается элемент «p»? вход находится внутри «p»? потому что вам нужно получить селектор на основе этого элемента. – lauda
Подтвержденный код –