1

My form has two select boxes in which the user can pick countries to be included in the settings. The values of the available options look like this:

<option value="AU">Australia</option>

When the form is submitted, chrome reports the state of the select like this:

f_countries:selectedc
selectedcountries[]:AU
selectedcountries[]:AR

On casperjs I can use the following method to do things such as type in input boxes, etc., on the form. What I can't figure out is how to set the select form values to those listed above.

For example, say I wanted to set the selected countries to "US,CA,BR".

Here is what I use for other types of input on the forms.

this.fill('form#my_form', { 
'username': 'joe',
'password': 'secret',
'f_countries:selectedc': [[ can't figure out what goes here ]]
}, true); 

Question is: how do I use casperjs to set the values of selects on forms.

Artjom B.
  • 59,901
  • 24
  • 121
  • 211
Kevin
  • 3,584
  • 4
  • 29
  • 35
  • Are both select boxes named the same or do you mean a multi-select box? Please show more of the markup (just selects and options). – Artjom B. Jun 27 '14 at 22:36
  • Possible duplicate of [CasperJS/ Javascript Selecting Multiple Options](http://stackoverflow.com/questions/30986521/casperjs-javascript-selecting-multiple-options) – Artjom B. Mar 29 '16 at 19:50

1 Answers1

0

If it is a simple select box, try using

selector : 'value'

if it is a multi select box , refer to https://groups.google.com/forum/#!topic/casperjs/1iObXfhfbUU

Srikanth Malyala
  • 860
  • 14
  • 23