Class: Selenium::WebDriver::Logs

Inherits:
Object
  • Object
show all
Defined in:
lib/automation_helpers/extensions/selenium/webdriver/logs.rb

Overview

Additional useful methods to extend the Selenium::WebDriver::Logs class with

Instance Method Summary collapse

Instance Method Details

#get(type) ⇒ Hash

Identical to the regular log fetch from Selenium, but stores the logs inside a Hash to be writable later

Returns:

  • (Hash)


12
13
14
# File 'lib/automation_helpers/extensions/selenium/webdriver/logs.rb', line 12

def get(type)
  cached_logs[type] = @bridge.log(type)
end

#write_log_to_file(type, file = default_file_path) ⇒ Integer

Write the logs to a filepath (If provided), or default file path (Configured). Returns the filesize as per the regular Ruby Filesystem method

Returns:

  • (Integer)


20
21
22
23
24
25
26
27
28
29
30
# File 'lib/automation_helpers/extensions/selenium/webdriver/logs.rb', line 20

def write_log_to_file(type, file = default_file_path)
  get(type) unless cached_logs.key?(type)

  cached_logs[type].each do |log_entry|
    if file == $stdout
      file << log_entry
    else
      File.write(file, log_entry)
    end
  end
end