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!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response