Sha256: 562f00859f46cbf03b4719cbf35e1fa559b49267cef0c6bd8dfaa99ad98aff1c

Contents?: true

Size: 1.4 KB

Versions: 19

Compression:

Stored size: 1.4 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|
          begin
            ::Selenium::WebDriver::LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
          rescue KeyError
            next
          end
        end
      rescue ::Selenium::WebDriver::Error::UnknownCommandError
        raise NotImplementedError, LOG_MSG
      end
    end
  end
end

Version data entries

19 entries across 17 versions & 3 rubygems

Version Path
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/capybara-3.32.2/lib/capybara/selenium/patches/logs.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/capybara-3.32.2/lib/capybara/selenium/patches/logs.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/selenium/patches/logs.rb
capybara-3.32.2 lib/capybara/selenium/patches/logs.rb
capybara-3.32.1 lib/capybara/selenium/patches/logs.rb
capybara-3.32.0 lib/capybara/selenium/patches/logs.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/capybara-3.29.0/lib/capybara/selenium/patches/logs.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/capybara-3.31.0/lib/capybara/selenium/patches/logs.rb
capybara-3.31.0 lib/capybara/selenium/patches/logs.rb
capybara-3.30.0 lib/capybara/selenium/patches/logs.rb
tdiary-5.1.0 vendor/bundle/gems/capybara-3.29.0/lib/capybara/selenium/patches/logs.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/selenium/patches/logs.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/capybara-3.29.0/lib/capybara/selenium/patches/logs.rb
capybara-3.29.0 lib/capybara/selenium/patches/logs.rb
capybara-3.28.0 lib/capybara/selenium/patches/logs.rb
capybara-3.27.0 lib/capybara/selenium/patches/logs.rb
capybara-3.26.0 lib/capybara/selenium/patches/logs.rb
capybara-3.25.0 lib/capybara/selenium/patches/logs.rb
capybara-3.24.0 lib/capybara/selenium/patches/logs.rb