我正在尝试编写一个自动化脚本来验证Kendo Date选择器控件,但它没有按预期格式发送值。
自动化脚本
describe('Submit a form with date values ', function () {
it('Should submit a form after entering all the required fields', function () {
var date_picker = element(by.xpath("//ca-datepicker[@name='enterDate']//input"));
date_picker.sendKeys("01/01/2015);
}
}
结果 它将该值发送为05 / day / 2015
HTML:
<html>
<body>
<ca-datepicker class="ca-datepicker ca-validation ng-untouched ng-pristine ng-invalid" _ngcontent-c23="" name="enterDate" required="" validatemin="">
<kendo-datepicker class="ca-datepicker__input k-widget k-datepicker k-header ng-untouched ng-pristine ng-valid">
<!---->
<span class="k-picker-wrap k-state-default">
<kendo-dateinput class="k-widget k-dateinput">
<!---->
<span class="k-dateinput-wrap">
<input class="k-input" autocapitalize="off" autocomplete="off" autocorrect="off" role="spinbutton" spellcheck="false" title="" tabindex="2" aria-expanded="false" aria-haspopup="true" aria-valuetext=""/>
<!---->
</span>
</kendo-dateinput>
<span class="k-select" role="button" title="Toggle calendar" aria-label="Toggle calendar" aria-controls="01109451-42bb-40a9-abb4-fc148dca7114">
<span class="k-icon k-i-calendar"/>
</span>
</span>
<!---->
<!---->
</kendo-datepicker>
<!---->
</ca-datepicker>
</body>
<html>
&#13;
答案 0 :(得分:0)
请改为input
级别:
var date_picker = element(by.class('k-input'));
答案 1 :(得分:0)
始终将日期设置为当前日期,以便将来测试始终正常运行。
// get today's date
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = mm+'/'+dd+'/'+yyyy;
date_picker.clear();
date_picker.sendKeys(today);