I\'m trying to create a testing case for a web site which includes a form with 3 chained selects. The first select is populated by default when the web page is loaded. If an
The right and easiest way to do this is to fire 'onchange' event on the first select after you changed value to need option, then the same on the second one:
//...
// the first select
casperjs.thenEvaluate(function() {
var sel1 = document.getElementById('s1');
sel1.value = 3;
var evt = document.createEvent('HTMLEvents');
evt.initEvent('change', true, false);
sel1.dispatchEvent(evt);
});
// the second select
casperjs.thenEvaluate(function() {
var sel2 = document.getElementById('s2');
sel2.value = 'someVal2'; // guess, you know needed value
var evt = document.createEvent('HTMLEvents');
evt.initEvent('change', true, false);
sel2.dispatchEvent(evt);
});
// the third select
casperjs.thenEvaluate(function() {
var sel3 = document.getElementById('s3');
sel3.value = 'someVal3'; // guess, you know needed value
var evt = document.createEvent('HTMLEvents');
evt.initEvent('change', true, false);
sel3.dispatchEvent(evt);
});
casperjs.then(function() {
// your verifications here
});