Add log extension commands coming in chromedriver 76/77 to Chrome bridge
@@ -25,7 +25,9 @@ module Selenium
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)
@@ -44,6 +46,22 @@ module Selenium
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
