Capybara poltergeist not working

I don't know how to click the href link in the polytergeist capybara, I have some sample code like this in my testing

it "test", :driver => :poltergeist do
  page.find("#link1").click 
end

and in my html, I have an example like this

<table class="index">
  <tbody>
    <tr>
      <td><a href="http://localhost:3000/users/3" id="link1">hey click me</a></td>
    </tr>
  </tbody>
</table>

how to click link in capybara poltergeist? I'm already trying "click_link", "click_button" and any other, but still not working

+4
source share
1 answer

I would try to use

 all(:xpath,'//a[@id="link1"]').first.click

or  find(:xpath,'//a[@id="link1"]').trigger('click')

If this is ambiguous, you can add more details, for example

find(:xpath,'//a[@id="link1"]', :text => 'hey click me').trigger('click')

+1
source

All Articles