0

I'm writing a script in Protractor and I have a calendar in my angular application.

I used element(by.css('Today's date')).click(); to select today's date from the calender. But, I have to change the code everyday to select the today's date.

So, Is there a specific anyway to select the today's date from the calendar?

Thanks. :)

1 Answers1

1

Use the following code.

 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);

For more information look at alecxe's answer here.

Hope this helps. :)

Community
  • 1
  • 1
Manuli
  • 1,203
  • 4
  • 20
  • 43