3
votes

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.

enter image description here

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?

1
What is the issue that you find with this.expiryDatePicker = dvr.findElement(by.css('#expiry_datepicker')); - Sakshi Singla
No issue with the calendar per se, but .sendKeys(date) doesn't work and validation is thrown regarding me passing through a valid date. - Ryan Drake
doesn't work means?? Send the error - Sakshi Singla
Throws validation error. "Sorry, you must select an expiry date before you send your message." - Ryan Drake
mmmm..sendkeys doesn't enter anything? and gives no error on sendkeys code line? - Sakshi Singla

1 Answers

1
votes

You can do it through executeScript():

dvr.executeScript("arguments[0].val(arguments[1]);", page.expiryDatePicker.getWebElement(), "26-Apr-16");