Sha256: 9afe87763c6f5343c302032188394b276f8940e4845972fb2225c7de3e1610bc

Contents?: true

Size: 1.33 KB

Versions: 35

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module Capybara
  module Selenium
    module ChromeLogs
      LOG_MSG = <<~MSG
        Chromedriver 75+ defaults to W3C mode. Please upgrade to chromedriver >= \
        75.0.3770.90 if you need to access logs while in W3C compliant mode.
      MSG

      COMMANDS = {
        get_available_log_types: [:get, 'session/:session_id/se/log/types'],
        get_log: [:post, 'session/:session_id/se/log'],
        get_log_legacy: [:post, 'session/:session_id/log']
      }.freeze

      def commands(command)
        COMMANDS[command] || super
      end

      def available_log_types
        types = execute :get_available_log_types
        Array(types).map(&:to_sym)
      rescue ::Selenium::WebDriver::Error::UnknownCommandError
        raise NotImplementedError, LOG_MSG
      end

      def log(type)
        data = begin
          execute :get_log, {}, type: type.to_s
        rescue ::Selenium::WebDriver::Error::UnknownCommandError
          execute :get_log_legacy, {}, type: type.to_s
        end

        Array(data).map do |l|
          ::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
        rescue KeyError
          next
        end
      rescue ::Selenium::WebDriver::Error::UnknownCommandError
        raise NotImplementedError, LOG_MSG
      end
    end
  end
end

Version data entries

35 entries across 25 versions & 4 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/capybara-3.40.0/lib/capybara/selenium/patches/logs.rb
capybara-3.40.0 lib/capybara/selenium/patches/logs.rb
capybara-3.39.2 lib/capybara/selenium/patches/logs.rb
capybara-3.39.1 lib/capybara/selenium/patches/logs.rb
capybara-3.39.0 lib/capybara/selenium/patches/logs.rb
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/capybara-3.36.0/lib/capybara/selenium/patches/logs.rb
capybara-3.38.0 lib/capybara/selenium/patches/logs.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/capybara-3.37.1/lib/capybara/selenium/patches/logs.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/capybara-3.37.1/lib/capybara/selenium/patches/logs.rb
capybara-3.37.1 lib/capybara/selenium/patches/logs.rb
capybara-3.37.0 lib/capybara/selenium/patches/logs.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/capybara-3.36.0/lib/capybara/selenium/patches/logs.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/capybara-3.36.0/lib/capybara/selenium/patches/logs.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selenium/patches/logs.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.36.0/lib/capybara/selenium/patches/logs.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.36.0/lib/capybara/selenium/patches/logs.rb
capybara-3.36.0 lib/capybara/selenium/patches/logs.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selenium/patches/logs.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/capybara-3.35.3/lib/capybara/selenium/patches/logs.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/capybara-3.35.3/lib/capybara/selenium/patches/logs.rb