diff --git a/CHANGELOG.md b/CHANGELOG.md index 49c98f3..972a602 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,12 @@ ### Added ### Changed +- `@window_size` attribute is moved from Ferrum viewport size is still inherited [#253] ### Fixed - Detect whether element is in the viewport and clickable before click [#251] - Remember parentNode in case onChange callback mutates DOM [#227] +- Correctly open devtools page when calling `debug` [#252] ### Removed diff --git a/lib/capybara/cuprite/browser.rb b/lib/capybara/cuprite/browser.rb index 12e08a4..d817a20 100644 --- a/lib/capybara/cuprite/browser.rb +++ b/lib/capybara/cuprite/browser.rb @@ -11,7 +11,7 @@ class Browser < Ferrum::Browser find_modal accept_confirm dismiss_confirm accept_prompt dismiss_prompt reset_modals] => :page - attr_reader :url_blacklist, :url_whitelist + attr_reader :url_blacklist, :url_whitelist, :window_size alias url_blocklist url_blacklist alias url_allowlist url_whitelist @@ -22,6 +22,7 @@ def initialize(options = nil) self.url_whitelist = options[:url_whitelist] super + @window_size = @options.window_size @page = false end @@ -38,6 +39,7 @@ def page def reset super + @window_size = options.window_size @page = attach_page end @@ -46,6 +48,11 @@ def quit @page = false end + def resize(**options) + @window_size = [options[:width], options[:height]] + super + end + def url_whitelist=(patterns) @url_whitelist = prepare_wildcards(patterns) page.network.whitelist = @url_whitelist if @client && @url_whitelist.any? diff --git a/lib/capybara/cuprite/page.rb b/lib/capybara/cuprite/page.rb index 3a4ce09..8f2977e 100644 --- a/lib/capybara/cuprite/page.rb +++ b/lib/capybara/cuprite/page.rb @@ -134,6 +134,9 @@ def title def prepare_page super + width, height = @browser.window_size + resize(width: width, height: height) + if @browser.url_blacklist.any? network.blacklist = @browser.url_blacklist elsif @browser.url_whitelist.any?