Skip to content

Commit 02234d5

Browse files
committed
Include process output in ProcessTimeoutError
Helps diagnose Chrome setup issues, similar to: #78
1 parent 4ff62fb commit 02234d5

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

lib/ferrum.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ def message
3737
end
3838

3939
class ProcessTimeoutError < Error
40-
def initialize(timeout)
40+
attr_reader :output
41+
42+
def initialize(timeout, output)
43+
@output = output
4144
super("Browser did not produce websocket url within #{timeout} seconds")
4245
end
4346
end

lib/ferrum/browser/process.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def parse_ws_url(read_io, timeout)
144144

145145
unless ws_url
146146
@logger.puts(output) if @logger
147-
raise ProcessTimeoutError.new(timeout)
147+
raise ProcessTimeoutError.new(timeout, output)
148148
end
149149
end
150150

spec/browser_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ module Ferrum
6464
)
6565
end
6666

67+
it "includes the process output in the error" do
68+
path = "#{PROJECT_ROOT}/spec/support/broken_chrome"
69+
70+
expect {
71+
Browser.new(browser_path: path)
72+
}.to raise_error(Ferrum::ProcessTimeoutError) do |ex|
73+
expect(ex.output).to include "Broken Chrome error message"
74+
end
75+
end
76+
6777
it "raises an error and restarts the client if the client dies while executing a command" do
6878
expect { browser.crash }.to raise_error(Ferrum::DeadBrowserError)
6979
browser.goto

spec/support/broken_chrome

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
echo "Broken Chrome error message"
4+
echo "$0"
5+
exit 1

0 commit comments

Comments
 (0)