I posted this on the github issue tracker, where it was suggested I ask over here.
Issue: When I use .setValue() on an input of type="date", the next time I call .value() on the input, the date is way off.
Example test:
'Setting Date Field' : function(browser) {
browser.url('http://adam.goucher.ca/parkcalc/'); // fun website to test
var targetDate = '2016-11-12';
// Create date field
browser.execute(
function() {
var elemDiv = document.createElement('input');
elemDiv.id="onlyDate";
elemDiv.type="Date";
document.body.appendChild(elemDiv);
}
).pause(300); // pause rather than using a callback
browser.setValue('#onlyDate',targetDate);
browser.expect.element('#onlyDate').to.have.value.which.is.equal(targetDate);
browser.end();
},
Result:
Expected element <#onlyDate> to have value which equals "2016-11-12" - expected "equals '2016-11-12'" but got: "61112-02-01".
From what I can tell, this is because the DATE input in chrome looks like this: mm-dd-yyyy (by default), and when .setValue() sends the keypresses for "2016-11-12", the focus starts on the mm part and proceeds "automatically" from there. Obviously typing in the exact kepyresses of 2016-11-12 will not set the value properly.
How do others set the value of input=date and input=time fields?