ruby-on-railsruby-on-rails-3testingrspeccapybara

How do i click this button in capybara


Please help me solve this problem with capybara

I have a button like this in capybara:

<input type="submit" value="Verify" name="verify" id="verify" class="button">

I tried with

click_button "verify"

but it gives error:

Failure/Error: find('#verify').click
NoMethodError:
  undefined method `node_name' for nil:NilClass

Solution

  • Answer by the author

    The problem lies inside the html code:

    <div>
    <form>
    <div>    
    </div>
    </div>
      <input type="submit" value="Verify" name="verify" id="verify" class="button">
    </form>
    

    Because there is one redundant </div>, the <input> was treat outside the form, hence capybara cause those error. After delete the redundant </div>, everything works fine.