From a51c2c36b5e6a09a14163a14292f1ad6b327f21c Mon Sep 17 00:00:00 2001 From: Dmitry Vorotilin Date: Thu, 19 Nov 2026 16:35:20 +0300 Subject: [PATCH 1/2] chore(deps): use ferrum main until the next release --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index 6dbf95d..63d7431 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "byebug", "~> 11.1", platforms: %i[mri windows] +gem "ferrum", github: "rubycdp/ferrum", branch: "main" gem "launchy", "~> 2.5" gem "logger" gem "ostruct" From df8efdc6d1fc557e8ec7d79ab16d3e912f690689 Mon Sep 17 00:00:00 2001 From: Dmitry Vorotilin Date: Thu, 19 Nov 2026 16:43:23 +0300 Subject: [PATCH 2/2] fix(browser): remove a closed window from the default context instead of a copy of its targets Ferrum 0.21 returns a copy from Context#targets, so deleting from it kept a closed window listed until Chrome reported it destroyed: exists? stayed true and switching to it raised BrowserError instead of NoSuchPageError. --- CHANGELOG.md | 2 ++ lib/capybara/cuprite/browser.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 814dbd0..b3ea17d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ - `:pending_connection_errors` is handled by Cuprite instead of being passed to Ferrum, which deprecates it. `visit` raises `Capybara::Cuprite::PendingConnectionsError`, a subclass of Ferrum's, and rescuing Ferrum's warns [rubycdp/ferrum#689] +- A closed window is removed from Ferrum's context, which returns a copy of its targets, so `close_window` no longer + leaves it listed until Chrome reports it destroyed [rubycdp/ferrum#707] ### Fixed - A click on a node the page removes before the hit test raises `ObsoleteNode`, which Capybara retries, instead of diff --git a/lib/capybara/cuprite/browser.rb b/lib/capybara/cuprite/browser.rb index 6d8db60..a53fd97 100644 --- a/lib/capybara/cuprite/browser.rb +++ b/lib/capybara/cuprite/browser.rb @@ -77,7 +77,7 @@ def close_window(target_id) @page_closed = true end target.page.close - targets.delete(target_id) # page.close is async, delete target asap + default_context.delete_target(target_id) # page.close is async, delete target asap end private