Pull in system logs from /tmp/flaky_logs.txt

def save_logs
  file = '/tmp/flaky_logs.txt'
  logs = nil

  begin
    logs = $driver.driver.manage.logs.get(:logcat)
  rescue # try iOS
    logs = $driver.driver.manage.logs.get(:syslog)
  end

  File.open(file, 'w') do |f|
    # Save only the message from Selenium::WebDriver::LogEntry
    f.write (logs.map { |line| line.message }).join("\n")
  end
end

Minitest.after_run do
  if $driver
    save_logs
    $driver.x
  end
end