Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Move window_size to Ferrum #253

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading