tardjo
tardjo

Reputation: 1654

capybara poltergeist click not working

i dont know how to click link href in capybara poltergeist, i have sample code like this in my testing

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

and in my html, i have sample 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 already try "click_link", "click_button" and any else but still not working

Upvotes: 4

Views: 3942

Answers (1)

安杰帅
安杰帅

Reputation: 334

I would try using

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

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

If that's ambiguous, you can add on more details such as

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

Upvotes: 2

Related Questions