DEV Community

n350071πŸ‡―πŸ‡΅
n350071πŸ‡―πŸ‡΅

Posted on β€’ Edited on

5 1

click link in Capybara

πŸ”— Parent Note

πŸ‘ Way1: Usual way.

Capybara::Node::Actions#click_link is easy.

You can just type the text. This example click the link of dev.to edit link.

click_link('EDIT')

Also, you can do this.

click_link(href: "/n350071/my-capybara-note-2gp3/edit")

But, if the page has 2 or 3 of same link? You will face to Ambiguous match error.

πŸ‘ Way2: Workaround

You can use find and find_all method.

find('a[href="/n350071/my-capybara-note-2gp3/edit"]') 

find_all('a[href="/n350071/my-capybara-note-2gp3/edit"]').each do
  # do something
  # back
  page.go_back
end

If you want to click button,

click_button('SUBMIT')

Top comments (0)

Hot sauce if you're wrong - web dev trivia for staff engineers

Hot sauce if you're wrong Β· web dev trivia for staff engineers (Chris vs Jeremy, Leet Heat S1.E4)

  • Shipping Fast: Test your knowledge of deployment strategies and techniques
  • Authentication: Prove you know your OAuth from your JWT
  • CSS: Demonstrate your styling expertise under pressure
  • Acronyms: Decode the alphabet soup of web development
  • Accessibility: Show your commitment to building for everyone

Contestants must answer rapid-fire questions across the full stack of modern web development. Get it right, earn points. Get it wrong? The spice level goes up!

Watch Video 🌢️πŸ”₯

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay