Skip to content

Commit 9ce609f

Browse files
committed
Rescue exception while saving artifacts
1 parent 605c620 commit 9ce609f

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

spec/spec_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,23 @@ def save_exception_aftifacts(browser, meta)
109109
line_number = meta[:line_number]
110110
timestamp = "#{time_now.strftime('%Y-%m-%d-%H-%M-%S.')}#{'%03d' % (time_now.usec/1000).to_i}"
111111

112+
save_exception_log(filename, line_number, timestamp)
113+
save_exception_screenshot(filename, line_number, timestamp)
114+
end
115+
116+
def save_exception_screenshot(filename, line_number, timestamp)
112117
screenshot_name = "screenshot-#{filename}-#{line_number}-#{timestamp}.png"
113118
screenshot_path = "/tmp/cuprite/#{screenshot_name}"
114119
browser.screenshot(path: screenshot_path, full: true)
120+
rescue => e
121+
puts "#{e.class}: #{e.message}"
122+
end
115123

124+
def save_exception_log(filename, line_number, timestamp)
116125
log_name = "logfile-#{filename}-#{line_number}-#{timestamp}.txt"
117126
File.open("/tmp/cuprite/#{log_name}", "wb") { |f| f.write(browser.logger.string) }
127+
rescue => e
128+
puts "#{e.class}: #{e.message}"
118129
end
119130

120131
def remove_temporary_folders

0 commit comments

Comments
 (0)