I'm trying to test validation on a non-Angular page, which requires an expiry date for a message, of which I'm using jQuery's datepicker.

In Chrome's console, I can simply pass through the value for the input field:
$('#expiry_datepicker').val("26-Apr-16")
So I thought I'd be able to send through that same value in Protractor:
// Page Object
this.expiryDatePicker = dvr.findElement(by.css('#expiry_datepicker'));
// Spec File
page.expiryDatePicker.sendKeys( '29-Apr-2016' );
However, that doesn't work. I then tried to click on the input field and then tried to click the element $('.ui-datepicker-current-day') but no luck with that either.
Anyone have ideas about being able to drive Selenium to select the date?
You can do it through executeScript():
dvr.executeScript("arguments[0].val(arguments[1]);", page.expiryDatePicker.getWebElement(), "26-Apr-16");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With