Nightwatch: Using .setValue() on a select element doesn't cause the change event to fired

Created on 21 Sep 2016  路  2Comments  路  Source: nightwatchjs/nightwatch

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!

All 2 comments

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:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zechtitus picture Zechtitus  路  4Comments

dakebl picture dakebl  路  4Comments

willli666 picture willli666  路  3Comments

davecranwell picture davecranwell  路  3Comments

chaseconey picture chaseconey  路  4Comments