Skip to content

Commit

Permalink
Add log extension commands coming in chromedriver 76/77 to Chrome bri…
Browse files Browse the repository at this point in the history
…dge (#7276)
  • Loading branch information
twalpole committed Jun 24, 2019
1 parent 8d1cc16 commit f4f5881
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion rb/lib/selenium/webdriver/chrome/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ module Bridge
COMMANDS = {
get_network_conditions: [:get, 'session/:session_id/chromium/network_conditions'],
set_network_conditions: [:post, 'session/:session_id/chromium/network_conditions'],
send_command: [:post, 'session/:session_id/goog/cdp/execute']
send_command: [:post, 'session/:session_id/goog/cdp/execute'],
get_available_log_types: [:get, 'session/:session_id/se/log/types'],
get_log: [:post, 'session/:session_id/se/log']
}.freeze

def commands(command)
Expand All @@ -44,6 +46,22 @@ def network_conditions=(conditions)
execute :set_network_conditions, {}, {network_conditions: conditions}
end

def available_log_types
types = execute :get_available_log_types
Array(types).map(&:to_sym)
end

def log(type)
data = execute :get_log, {}, {type: type.to_s}

Array(data).map do |l|
begin
LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
rescue KeyError
next
end
end
end
end # Bridge
end # Chrome
end # WebDriver
Expand Down

0 comments on commit f4f5881

Please sign in to comment.