1

I have the following form element

<div class="control-group no-margin">
        <div class="controls">
                <label for="user_terms_and_conditions" class="checkbox">
                    <input id="user_terms_and_conditions" name="user[terms_and_conditions]" type="checkbox" > I accept the Open Vault <a href="/blog/terms-and-conditions">Terms &amp; Conditions</a>
            </label>
            </div>
        </div>

but my capybara test is not properly checking the checkbox with the following

check 'user_terms_and_conditions' unless terms_and_conditions.nil?

or

find('#user_terms_and_conditions').set(true) unless terms_and_conditions.nil?

What am I doing wrong? There is a validation in the model to make sure its true and it keeps returning the error that this must be checked. When i do this with my eyeballs in the browser it works fine.

jwilcox09
  • 721
  • 5
  • 18
  • P.S. i've already tried http://stackoverflow.com/a/8297992/818007 and http://stackoverflow.com/questions/11549345/checking-checkboxes-with-capybara – jwilcox09 Jul 10 '13 at 19:48
  • Are you sure that `terms_and_conditions.nil?` is `false`? The capybara portion of your code works fine for me. – Justin Ko Jul 11 '13 at 08:12
  • Yeah i have tried excluding that entirely so that is check its regardless since its required – jwilcox09 Jul 11 '13 at 12:24

1 Answers1

0

Turns out switching from selenium to webkit for the default_driver was all it needed to work. For some reason selenium didn't like checking checkboxes in my environment. I suppose I should have just used webkit from the start.

jwilcox09
  • 721
  • 5
  • 18