I am using Capybara 2.4.4 to click a link. The html is like this:
<a name="skiplink" id="skiplink" type="button" href="javascript:void(0);" onclick="skipForm(); return false;">salta</a>
Capybara command:
find("a", :text => "salta").click
find('skiplink').click
none of both works:
Failure/Error: find("a", :text => "salta").click
NoMethodError:
undefined method `empty?' for nil:NilClass
I have copied-pasted the html from save_and_open_page
output so it may be correct
I am using default driver (no selenium)
Thanks
Either of the following should work
click_on('salta')
find(:css, '#skiplink').click # the :css is only necessary if you've changed capybaras default selector
your find("a", :text => "salta").click should work too -- however when using capybaras default driver (racktest) clicking on javascript links isn't going to work since the driver doesn't support javascript. You need to switch to a different driver (selenium, capybara-webkit, poltegeist, etc.) that supports javascript
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With