Module: Selenium::WebDriver::Chrome::Bridge

Defined in:
lib/selenium/webdriver/chrome/bridge.rb

Constant Summary collapse

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'],
  get_available_log_types: [:get, 'session/:session_id/se/log/types'],
  get_log: [:post, 'session/:session_id/se/log']
}.freeze

Instance Method Summary collapse

Instance Method Details

#available_log_typesObject


49
50
51
52
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 49

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

#commands(command) ⇒ Object


33
34
35
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 33

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

#log(type) ⇒ Object


54
55
56
57
58
59
60
61
62
63
64
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 54

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

#network_conditionsObject


37
38
39
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 37

def network_conditions
  execute :get_network_conditions
end

#network_conditions=(conditions) ⇒ Object


45
46
47
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 45

def network_conditions=(conditions)
  execute :set_network_conditions, {}, {network_conditions: conditions}
end

#send_command(command_params) ⇒ Object


41
42
43
# File 'lib/selenium/webdriver/chrome/bridge.rb', line 41

def send_command(command_params)
  execute :send_command, {}, command_params
end