Aurélien B
Aurélien B

Reputation: 4640

Use a select outside of a form with CasperJS

I want to select an entry into a select. How I can do that with CasperJS.

Some information you need to know :

Upvotes: 2

Views: 286

Answers (1)

Fanch
Fanch

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

Related Questions