How can I click below link with Capybara's click_link method?
<a data-method="delete" href="/users/sign_out" rel="nofollow">
<span title="Sign out" class="glyphicon glyphicon-off"></span>
</a>
You could locate the element using its href attribute:
page.click_link('', :href => '/users/sign_out')
Note that the first parameter of click_link
is the links text, id or name. We use '' since the text is blank.
Alternatively, use the find method to find the link using the href attribute (or any other attribute) and then click it.
page.find(:css, 'a[href="/users/sign_out"]').click
Add id
to link and use its id
.
click_link('link_id')
More info here
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