Skip to content
Open
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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## [Unreleased] ##

### Added

### Changed
- `Ferrum::Browser` option `:pending_connection_errors` is set to false by default

### Fixed


## [Unreleased](https://github.com/rubycdp/ferrum/compare/v0.17.1...main) ##

### Added
Expand Down
2 changes: 1 addition & 1 deletion docs/2-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Ferrum::Browser.new(options)
communicating with browser. Default is 5.
* `:js_errors` (Boolean) - When true, JavaScript errors get re-raised in Ruby.
* `:pending_connection_errors` (Boolean) - Raise `PendingConnectionsError` when main frame is still waiting
for slow responses and timeout is reached. Default is true.
for slow responses and timeout is reached. Default is false.
* `:browser_name` (Symbol) - `:chrome` by default, only experimental support
for `:firefox` for now.
* `:browser_path` (String) - Path to Chrome binary, you can also set ENV
Expand Down
2 changes: 1 addition & 1 deletion lib/ferrum/browser/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(options = nil)
@incognito = @options.fetch(:incognito, true)
@dockerize = @options.fetch(:dockerize, false)
@flatten = @options.fetch(:flatten, true)
@pending_connection_errors = @options.fetch(:pending_connection_errors, true)
@pending_connection_errors = @options.fetch(:pending_connection_errors, false)
@process_timeout = @options.fetch(:process_timeout, PROCESS_TIMEOUT)
@slowmo = @options[:slowmo].to_f

Expand Down
4 changes: 2 additions & 2 deletions spec/browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@
end

it "supports :pending_connection_errors argument" do
browser = Ferrum::Browser.new(base_url: base_url, pending_connection_errors: false, timeout: 0.5)
browser = Ferrum::Browser.new(base_url: base_url, pending_connection_errors: true, timeout: 0.5)

expect { browser.go_to("/really_slow") }.not_to raise_error
expect { browser.go_to("/really_slow") }.to raise_error(Ferrum::PendingConnectionsError)
ensure
browser&.quit
end
Expand Down
7 changes: 1 addition & 6 deletions spec/network/exchange_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,7 @@
it "determines if exchange is not fully loaded" do
allow(page).to receive(:timeout) { 2 }

expect do
page.go_to("/visit_timeout")
end.to raise_error(
Ferrum::PendingConnectionsError,
%r{Request to http://.*/visit_timeout reached server, but there are still pending connections: http://.*/really_slow}
)
page.go_to("/visit_timeout")

expect(last_exchange.pending?).to be true
end
Expand Down
3 changes: 3 additions & 0 deletions spec/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

it "reports pending connection for image" do
with_timeout(2) do
allow(browser.options).to receive(:pending_connection_errors).and_return(true)
expect { browser.go_to("/visit_timeout") }.to raise_error(
Ferrum::PendingConnectionsError,
%r{Request to http://.*/visit_timeout reached server, but there are still pending connections: http://.*/really_slow}
Expand All @@ -34,6 +35,7 @@

it "reports pending connection for main frame" do
with_timeout(0.5) do
allow(browser.options).to receive(:pending_connection_errors).and_return(true)
expect { browser.go_to("/really_slow") }.to raise_error(
Ferrum::PendingConnectionsError,
%r{Request to http://.*/really_slow reached server, but there are still pending connections: http://.*/really_slow}
Expand Down Expand Up @@ -164,6 +166,7 @@

describe "#timeout=" do
it "supports to change timeout dynamically" do
allow(browser.options).to receive(:pending_connection_errors).and_return(true)
page.timeout = 4
expect { page.go_to("/really_slow") }.not_to raise_error

Expand Down
Loading