I'm new to Protractor. I need to select today's date from the date picker.
Is there a specific anyway to select the today's date from the date picker?
Thanks. :)
I'm new to Protractor. I need to select today's date from the date picker.
Is there a specific anyway to select the today's date from the date picker?
Thanks. :)
Please see my answer here
If you need to be more quick,
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);
Hope this helps. :)
This method will give you current date time with seconds:
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;
},