Capybara - Unable to Click Link

I am using Capybara 2.4.4 to click a link. The html looks like this:

<a name="skiplink" id="skiplink" type="button" href="javascript:void(0);" onclick="skipForm(); return false;">salta</a>

      

Capybara Team:

find("a", :text => "salta").click
find('skiplink').click

      

neither of the two works:

Failure/Error: find("a", :text => "salta").click
     NoMethodError:
       undefined method `empty?' for nil:NilClass

      

I copied-pasted the html from the output save_and_open_page

so that it can be correct

I am using the default driver (no selenium)

thank

+3


source to share


1 answer


Any 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 the capybaras default (racktest) driver, clicking on javascript links will not work as the driver does not support javascript. You need to switch to another driver (selenium, capybara-webkit, poltegeist, etc.) which supports javascript

+1


source







All Articles