Skip to content

Fix driver node frame switching#312

Open
myabc wants to merge 1 commit into
rubycdp:mainfrom
myabc:fix/switch-to-frame-driver-nodes
Open

Fix driver node frame switching#312
myabc wants to merge 1 commit into
rubycdp:mainfrom
myabc:fix/switch-to-frame-driver-nodes

Conversation

@myabc

@myabc myabc commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Allow Driver#switch_to_frame to accept Capybara::Cuprite::Node
  • Add regression coverage for switching frames with a driver node

Root Cause

Driver-level frame traversal can pass a Capybara::Cuprite::Node, but switch_to_frame only extracted frameId from wrapped Capybara::Node::Element instances. Direct driver nodes therefore pushed a nil frame handle and left the frame stack invalid.

Impact

Libraries that work below Capybara session DSL can now switch into iframe nodes returned by Cuprite driver APIs without losing context.

This change is needed to fully support Cuprite/Ferrum in another library: dequelabs/axe-core-gems#509

Validation

  • bundle exec rspec spec/features/session_spec.rb -e "frame support"
  • bundle exec rspec spec/features/driver_spec.rb:1637
  • git diff --check HEAD~1..HEAD

@myabc myabc marked this pull request as ready for review June 27, 2026 22:08
Copilot AI review requested due to automatic review settings June 27, 2026 22:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes driver-level frame switching so Capybara::Cuprite::Driver#switch_to_frame can accept a Capybara::Cuprite::Node (not only wrapped Capybara::Node::Element), and adds a regression spec covering that usage.

Changes:

  • Extend Driver#switch_to_frame to extract frameId from Capybara::Cuprite::Node#description.
  • Add a feature spec that switches to an iframe using a driver-returned node and validates the frame URL.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
spec/features/session_spec.rb Adds a regression spec for switching into a frame using a driver node.
lib/capybara/cuprite/driver.rb Allows switch_to_frame to accept Capybara::Cuprite::Node and derive the frameId handle.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/capybara/cuprite/driver.rb
@myabc myabc changed the title [codex] Fix driver node frame switching Fix driver node frame switching Jun 27, 2026
Driver-level frame traversal can pass `Capybara::Cuprite::Node`.

Resolve its `frameId` before switching so the frame stack stays valid.
@myabc myabc force-pushed the fix/switch-to-frame-driver-nodes branch from 7bf0c65 to ac3e49e Compare June 27, 2026 22:21
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.

2 participants