Reputation: 4640
I want to select an entry into a select. How I can do that with CasperJS.
Some information you need to know :
document.querySelector(MY_SELECT).selectedIndex = X;
method because changing the select (with normal behaviour) throw some event I need, and they are not thrown with simple affectation.Upvotes: 2
Views: 286
Reputation: 3274
Do you want to just simulate the normal behaviour? That's right in some issue manipulate the DOM isn't sufficient (the events are not thrown and so you can't send your form because the data isn't updated, and you have the errors of the ajax return). I've realized that when we're doing functional test, reproduce the user behaviour always works :) ->
this.mouse.down("selector of your select element");//press left button
this.mouse.up('selector of the option of your select element');//release left button
Example :
this.mouse.down("div#ec1 select.jCustomSelect.monthB");//press left button
this.mouse.up('div#ec1 select.jCustomSelect.monthB > option[value="7"]');//release left button
Or you could use jQuery and the change() method.
Upvotes: 1