我是Protractor的新手。我需要从日期选择器中选择今天的日期。
是否有特定的选择从日期选择器中选择今天的日期?
感谢。 :)
答案 0 :(得分:2)
如果你需要更快,
var pickerDue = element(by.model("supplier.enroll_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 = yyyy+'-'+mm+'-'+dd;
pickerDue.clear();
pickerDue.sendKeys(today);
希望这会有所帮助。 :)
答案 1 :(得分:1)
此方法将为您提供以秒为单位的当前日期时间:
getCurrentDatemmddyyyy: function () {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
var hh = today.getHours();
var mins = today.getMinutes();
var ss = today.getSeconds();
if (dd < 10) {
dd = "0" + dd;
}
if (mm < 10) {
mm = "0" + mm;
}
if (hh < 10) {
hh = "0" + hh;
}
if (mins < 10) {
mins = "0" + mins;
}
if (ss < 10) {
ss = "0" + ss;
}
var today = mm + dd + yyyy + hh + mins + ss;
return today;
},