Skip to content

Commit

Permalink
chore: Move window_size to Ferrum (#253)
Browse files Browse the repository at this point in the history
* chore: Move window_size to Ferrum
  • Loading branch information
route authored Dec 21, 2023
1 parent 35d1dc2 commit 910ab59
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 8 additions & 1 deletion lib/capybara/cuprite/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -22,6 +22,7 @@ def initialize(options = nil)
self.url_whitelist = options[:url_whitelist]

super
@window_size = @options.window_size
@page = false
end

Expand All @@ -38,6 +39,7 @@ def page

def reset
super
@window_size = options.window_size
@page = attach_page
end

Expand All @@ -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?
Expand Down
3 changes: 3 additions & 0 deletions lib/capybara/cuprite/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 910ab59

Please sign in to comment.