我需要清除日期选择器的值。这是我的日期选择器DOM,
<p-calendar _ngcontent-c12="" id="startdate" name="startdate" required="" class="ng-tns-c13-9 ng-touched ng-dirty ui-inputwrapper-filled ng-valid">
<span class="ng-tns-c13-9 ui-calendar ui-calendar-w-btn">
<!---->
<input autocomplete="off" type="text" class="ng-tns-c13-9 ui-inputtext ui-widget ui-state-default ui-corner-all ng-star-inserted" name="startdate" required="" placeholder=""><!----><button class="ui-datepicker-trigger ui-calendar-button ng-tns-c13-9 ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ng-star-inserted" pbutton="" tabindex="-1" type="button"><span aria-hidden="true" class="ui-button-icon-left ui-clickable fa fa-fw fa-calendar"></span><span class="ui-button-text ui-clickable">ui-btn</span></button>
<div class="ng-tns-c13-9 ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-shadow ng-trigger ng-trigger-overlayState" style="display: none; z-index: 1020; top: -303px; left: 0px; opacity: 0;">
<!---->
<!---->
<!---->
<!---->
</div>
</span>
</p-calendar>
我在量角器中使用了以下代码来清除日期选择器并单击一些按钮。但是代码清除了该值,但是在单击下一个元素时,它再次在日期选择器输入框中加载了相同的值。手动,我可以清除并单击下一步按钮
this.verifyErrorMsgOfStartDate=function(){
browser.refresh();
basePage.waitForElement(this.txtBoxStartDate, basePage.timeout.xl);
browser.sleep(basePage.timeout.m);
basePage.clearText(this.txtBoxStartDate);
basePage.clearText(this.txtBoxStartDate);
basePage.clickElement(this.txtBoxStartDate);
browser.sleep(basePage.timeout.m);
console.log("cleared text");
basePage.clickElement(this.btnUpdate);
return this.errorMsg.getText().then(function (error) {
if(error[0]==="Start Date is required.")
return true;
});
};
和我的元素检查在下面,
this.txtBoxStartDate = $$('#startdate input');
this.btnUpdate = element(by.id('update-btn'));
如果有人可以帮助我!