Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-Angular Page + Protractor: sendKeys to date input field

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?

like image 596
Ryan Drake Avatar asked Nov 18 '25 14:11

Ryan Drake


1 Answers

You can do it through executeScript():

dvr.executeScript("arguments[0].val(arguments[1]);", page.expiryDatePicker.getWebElement(), "26-Apr-16");
like image 105
alecxe Avatar answered Nov 21 '25 04:11

alecxe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!