diff --git a/CHANGELOG.md b/CHANGELOG.md index 851e2cbe..fa15b885 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ - `Ferrum::PendingConnectionsError` and `Ferrum::TimeoutError` were swallowed even though it happens when a traffic iterator results in an empty array. [#583] - `webrick` is no longer a runtime dependency. It is only required by `Ferrum::Proxy`, so add `gem "webrick"` to your Gemfile if you use it. - Logger output for `Runtime.consoleAPICalled` now includes the console API type and stack trace call frames, not just the argument values [#605] +- `Ferrum::Browser` option `:pending_connection_errors` is set to false by default ### Removed - `webrick` runtime dependency dropped from the gemspec. `Ferrum::Proxy` still needs it, so add `gem "webrick"` to your Gemfile if you use the proxy server. diff --git a/docs/2-customization.md b/docs/2-customization.md index 095b6a5c..a2c2af74 100644 --- a/docs/2-customization.md +++ b/docs/2-customization.md @@ -31,7 +31,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 diff --git a/lib/ferrum/browser/options.rb b/lib/ferrum/browser/options.rb index ce98b9d5..9fe4b4d3 100644 --- a/lib/ferrum/browser/options.rb +++ b/lib/ferrum/browser/options.rb @@ -36,7 +36,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 diff --git a/spec/browser_spec.rb b/spec/browser_spec.rb index 4b76b7a4..139ebc55 100644 --- a/spec/browser_spec.rb +++ b/spec/browser_spec.rb @@ -241,9 +241,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 diff --git a/spec/network/exchange_spec.rb b/spec/network/exchange_spec.rb index 1d13917d..1e92c083 100644 --- a/spec/network/exchange_spec.rb +++ b/spec/network/exchange_spec.rb @@ -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 diff --git a/spec/page_spec.rb b/spec/page_spec.rb index ddf56c1c..429e9f42 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -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} @@ -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} @@ -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