Skip to content

feat(driver): open a window instead of a tab with open_new_window(:window) - #384

Merged
route merged 1 commit into
mainfrom
feat/open-new-window-kind
Nov 25, 2026
Merged

route merged 1 commit into
mainfrom
feat/open-new-window-kind

Conversation

@route

@route route commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Session#open_new_window(kind = :tab) passes kind only to a driver whose open_new_window takes an argument. Cuprite's took none, so open_new_window(:window) opened a tab.

  • Driver#open_new_window(kind = :tab) passes the kind to Browser#open_new_window, which calls default_context.create_target(new_window: kind == :window). Any other kind raises ArgumentError, as Selenium does.
  • Ferrum 0.21's create_target doesn't take new_window: yet. feat(context): open a window instead of a tab with new_window: ferrum#733 adds it, but that isn't released. lib/capybara/cuprite/context.rb prepends #733's version of the method to Ferrum::Context as Ferrum::Context::NewWindow. It waits on the target the way Ferrum does, with no polling. The prepend is skipped when Ferrum's own create_target already takes new_window:, so after the Ferrum release the file switches itself off and can be deleted.
  • Checked both ways: on released Ferrum 0.21.0 the patch is active, and on Ferrum main with #733 it's skipped. The specs pass on both.
  • 3 new specs under Driver#open_new_window. One checks that a tab shares the current window's window_id, one that :window gets its own, and one covers the ArgumentError.
  • YARD, RBS and a CHANGELOG line under Added.

…ndow)

Capybara passes the kind only to a driver whose open_new_window takes an argument, so :window opened a tab. It now calls
create_target(new_window: true). Ferrum 0.21 doesn't take new_window: yet, so Cuprite prepends rubycdp/ferrum#733's
create_target to Ferrum::Context unless Ferrum's already takes it. A kind other than :tab and :window raises ArgumentError.
@route
route force-pushed the feat/open-new-window-kind branch from 3ddd034 to 263791c Compare November 25, 2026 10:44
@route
route merged commit 801a3b2 into main Nov 25, 2026
6 checks passed
@route
route deleted the feat/open-new-window-kind branch November 25, 2026 11:03
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