Capybara. Find parent

author @no___tea

UPD [4/6/21]: you can use method ancestor from the master branch of the Capybara gem. doc

Just wrote mini-mini-minigem, which helps everybody to find parent node with RSpec and Capybara.

Gemfile

gem 'capybara_helpers'

spec/spec_helper.rb

require 'capybara_helpers'

Now, you’re able to use this little function

find('some_selector').parent_node

OR

find('some_selector').parent_node(level: 3)

to get HIGHer at the DOM.

Magic!

--

--