Skip to content

Commit 04620a5

Browse files
committed
[rb] fix bug hiding error information when selenium manager stdout is empty
1 parent c62fe6c commit 04620a5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

rb/lib/selenium/webdriver/common/selenium_manager.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,20 @@ def run(*command)
108108

109109
begin
110110
stdout, stderr, status = Open3.capture3(*command)
111-
json_output = stdout.empty? ? nil : JSON.parse(stdout)
112-
result = json_output['result']
113111
rescue StandardError => e
114112
raise Error::WebDriverError, "Unsuccessful command executed: #{command}; #{e.message}"
115113
end
116114

117-
(json_output&.fetch('logs') || []).each do |log|
115+
json_output = stdout.empty? ? {} : JSON.parse(stdout)
116+
(json_output['logs'] || []).each do |log|
118117
level = log['level'].casecmp('info').zero? ? 'debug' : log['level'].downcase
119118
WebDriver.logger.send(level, log['message'], id: :selenium_manager)
120119
end
121120

122-
if status.exitstatus.positive?
123-
raise Error::WebDriverError, "Unsuccessful command executed: #{command}\n#{result}#{stderr}"
124-
end
121+
result = json_output['result']
122+
return result unless status.exitstatus.positive?
125123

126-
result
124+
raise Error::WebDriverError, "Unsuccessful command executed: #{command}\n#{result}#{stderr}"
127125
end
128126
end
129127
end # SeleniumManager

0 commit comments

Comments
 (0)