Posted almost 2 years ago. Visible to the public. Repeats.

Capybara: Easiest way to get the parent of an element

If you already selected an element and want to get its parent, you can call find(:xpath, '..') on it.
To get the parents parent, call find(:xpath, '../..').


Find a link which contains a twitter icon and check that it links to the correct page:

<a href=""> <i class="icon is-twitter"></i> </a>
link = page.find("a").find(:xpath, '..') link[:href].should == ""

There is a good overview on xpath syntax on w3schools. But as xpath expressions can get quite complex and hard to understand for fellow developers, it's best to keep them short and simple.

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Judith Roth
Last edit:
almost 2 years ago
by Henning Koch
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Judith Roth to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more