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
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.
Try adding js: true
in the describe
. This happens when you do not have a form that contains the button.
Did you try "doubling up" the CSS selectors? This has been my go-to mechanism since capybara-2.4.3
find("#verify").find("[name=verify]").click
any other attribute in addition to the #id-vale should do the trick, e.g
find("#verify").find(".button]").click
If you have an ID for an element, just use @bonzofenix's approach but make it a bit more simple:
within 'form' do
find('#verify').click
end