Class: Capybara::Lightpanda::Browser::SeleniumCompat::Logs

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/lightpanda/browser/selenium_compat.rb

Overview

Selenium's driver.logs accessor. Only the :browser type has a meaning here; other Selenium log types (:driver, :client, :server) have no analogue and read as empty rather than raising, so a helper that probes several types still works.

Instance Method Summary collapse

Constructor Details

#initialize(browser) ⇒ Logs

Returns a new instance of Logs.



51
52
53
# File 'lib/capybara/lightpanda/browser/selenium_compat.rb', line 51

def initialize(browser)
  @browser = browser
end

Instance Method Details

#available_typesObject



67
68
69
# File 'lib/capybara/lightpanda/browser/selenium_compat.rb', line 67

def available_types
  [:browser]
end

#get(type = :browser) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/capybara/lightpanda/browser/selenium_compat.rb', line 55

def get(type = :browser)
  return [] unless type.to_sym == :browser

  @browser.console_logs.map do |entry|
    LogEntry.new(
      CONSOLE_LEVELS.fetch(entry[:type], "INFO"),
      entry[:text],
      entry[:timestamp]
    )
  end
end