Skip to content

Inspect Capybara nodes without walking into the driver - #316

Open
coorasse wants to merge 1 commit into
splitwise:mainfrom
coorasse:capybara-node-inspection
Open

coorasse wants to merge 1 commit into
splitwise:mainfrom
coorasse:capybara-node-inspection

Conversation

@coorasse

@coorasse coorasse commented Oct 20, 2026 •

Copy link
Copy Markdown

When a failing expectation involves a Capybara element (e.g. expect(page.find("button")).to be_disabled), SuperDiff builds the failure message by walking the element's instance variables.

An element holds the session, and through it the driver and the browser connection (pages, network traffic, sockets). With CDP-based drivers like Cuprite/Ferrum this takes minutes, so the spec looks like it's hanging.

This adds an inspection tree builder for Capybara::Node::Base and Capybara::Driver::Node that uses Capybara's own #inspect (e.g. #<Capybara::Node::Element tag="h1" path="/html/body/h1">), mirroring the existing ActionDispatch::Request builder. It's loaded by super_diff/rspec when Capybara is present, or explicitly via require "super_diff/capybara".

Capybara is added to the Rails appraisals so the unit specs can run against a real rack_test session.

A Capybara node holds the session, and through it the driver and the
browser connection. Walking its instance variables to build a failure
message can take minutes with CDP-based drivers, so nodes are rendered
with Capybara's own #inspect.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant