[rspec-users] issues when trying to select an option in a drop down list

Ben Atkin ben at benatkin.com
Thu Mar 1 05:56:12 UTC 2012


>From reading the error and the docs, it sounds like the last one:

select 'Honda', :from => "account[car_type]"

...should work. The one thing I can think of that might keep it from
working would be not being scoped to an area that includes the select box.
Perhaps you could install pry and add binding.pry above that line, and then
run it, and then poke around in the repl and see if you've got the right
context. You did make the request to get that page, right?

Ben

On Wed, Feb 29, 2012 at 10:04 PM, S Ahmed <sahmed1020 at gmail.com> wrote:

> My html looks like:
>
> <select id="account_car_type" name="account[car_type]"><option value="6
> ">Acura</option> <option value="7">Honda</option> <option value="8">Ford
> </option> <option value="9">Toyota</option> <option value="10">GM</option>
> </select>
> My requests spec looks like:
>
> before do
>   select '7', :from => "account[car_type]"
>   fill_in ..
>   ..
>
> end
>
> I get the error message:
>
>  Failure/Error: select '7', :from => "account[car_type]"
>      Capybara::ElementNotFound:
>        cannot select option, no option with text '7' in select box
> 'account[car_type]'
>      # (eval):2:in `select'
>      # ./spec/requests/account_pages_spec.rb:13:in `block (4 levels) in
> <top (required)>'
>
>
> I also tried:
>
> select 'Honda', :from => "account[car_type]"
>
> And got the same type of error.
>
> What am I doing wrong here?
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20120229/51a0625d/attachment.html>


More information about the rspec-users mailing list