0

I'm attempting to verify a value for a drop down using ruby's mechanize

I've got this pretty printed form:

Before:

#<Mechanize::Form
  ...
  [selectlist:0xefdae4 type:  name: time_entry[activity_id] value: []]}
  ...
 {buttons [submit:0xefe124 type: submit name: commit value: Save]}>

After:

#<Mechanize::Form
  ...
  [selectlist:0xefdae4 type:  name: time_entry[activity_id] value: []]}
  ...
 {buttons [submit:0xefe124 type: submit name: commit value: Save]}>

The code I'm running:

 @form.field_with(:name => "time_entry[activity_id]").options[2].select

... corresponding to the 3rd option: "Testing"

And the select HTML element:

<select id="time_entry_activity_id" name="time_entry[activity_id]">
  <option value="">--- Please select ---</option>
  <option value="8">Design</option>
  <option value="9">Development</option>
  <option value="13">Testing</option>
  <option value="14">Dingo</option>
  <option value="15">ABPs</option>
</select>

I'm attempting to get some kind of verification of what item is selected from the select box.

carl crott
  • 753
  • 1
  • 9
  • 21
  • Maybe I'm being dense because I'm fighting a cold, but I see absolutely no difference between the "Before" and "After" examples, nor does `vimdiff`. Want to clear this up for us? – the Tin Man Jan 07 '13 at 20:47

1 Answers1

1

Just inspect:

@form.field_with(:name => "time_entry[activity_id]").value

or maybe easier:

@form.values
pguardiario
  • 53,827
  • 19
  • 119
  • 159