I'm using Chrome. Assuming this isn't a ChromeDriver issue, and I don't think it's a selenium issue.
I'm using a JavaScript library (Vuex) that listens to the change event on an element to update a stored model which is then used when the form is submitted. It looks like setValue() doesn't cause that event to be fired, though.
This doesn't work when using Vuex or any other library that listens for the change event:
browser.setValue('.analytics-form .date-range', '7');
This does:
browser.execute(function () {
document.querySelector('.analytics-form .date-range').value = '7';
document.querySelector('.analytics-form .date-range').dispatchEvent(new Event('change'));
});
Obviously I'd prefer to not have to write the latter; it's a bit gross!
That's unfortunate but I'm afraid this isn't a Nightwatch issue, at least not one that we can fix. Maybe you can look through other reported issues with setValue to see if you can find any work-arounds: https://github.com/nightwatchjs/nightwatch/issues?utf8=%E2%9C%93&q=is%3Aissue%20setValue%20in%3Atitle. You can also try the Mailing List or StackOverflow.
Thank you :+1: