当我试图在量角器中找到'datepicker'时,我发现每次使用相同的class ='。datepicker'创建'datepicker'的实例/对象的新日期时,z-index的值增加,但是我想要处理单个对象,或者至少应该销毁旧对象/实例以找到新对象。
以下代码/片段将描述上述说明。
<!-- HTML CODE -->
<div class="form-group">
<label>Start Date</label>
<div class="input-group date form_datetime"
data-date- format="yyyy-mm-dd hh:ii"
data-link-field="dtp_input1">
<input class="form-control" size="16" ng-class="submitted:myScheduleForm.submitted}" ng-model="pollConfigInfo.startTime" readonly="" type="text" required=""/>
<span class="input-group-addon">
<i class="fa fa-times" style="cursor: pointer"></i>
</span>
<span class="input-group-addon">
<i class="fa fa-calendar" style="cursor: pointer"></i>
</span>
</div>
<input id="dtp_input1" value="" type="hidden"/>
</div>
JAVASCRIPT CODE:
<script>
$('.form_datetime').datetimepicker({
//language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
showMeridian: 1
});
</script>
Protractor Snippet选择datepicker
selectStartTimeAndDate:
{
value : function()
{
var picker = element(by.css('.fa-calendar'));
picker.click();
browser.driver.sleep(2000);
var day = element(by.cssContainingText('div.datetimepicker-days > table.table-condensed > tbody > tr > td.day','1'));
day.click();
var hour = element(by.cssContainingText('span.hour_am','12'));
hour.click();
var min = element(by.cssContainingText('span.minute','12:00'));
min.click();
}
},
答案 0 :(得分:0)
我通过像这样对量角器片段进行一些更改来得到答案:
var picker = element(by.css('.fa-calendar'));
picker.click();
browser.driver.sleep(2000);
var day = element.all(by.cssContainingText('div.datetimepicker-days > table.table-condensed > tbody > tr > td.day','1')).last();
day.click();
var hour = element.all(by.cssContainingText('span.hour_am','12')).last();
hour.click();
var min = element.all(by.cssContainingText('span.minute','12:00')).last();
min.click();