Module: Selenium::WebDriver::Chrome::Features

Included in:
Edge::Features
Defined in:
lib/selenium/webdriver/chrome/features.rb

Constant Summary collapse

CHROME_COMMANDS =
{
  launch_app: [:post, 'session/:session_id/chromium/launch_app'],
  get_cast_sinks: [:get, 'session/:session_id/goog/cast/get_sinks'],
  set_cast_sink_to_use: [:post, 'session/:session_id/goog/cast/set_sink_to_use'],
  start_cast_tab_mirroring: [:post, 'session/:session_id/goog/cast/start_tab_mirroring'],
  start_cast_desktop_mirroring: [:post, 'session/:session_id/goog/cast/start_desktop_mirroring'],
  get_cast_issue_message: [:get, 'session/:session_id/goog/cast/get_issue_message'],
  stop_casting: [:post, 'session/:session_id/goog/cast/stop_casting'],
  get_network_conditions: [:get, 'session/:session_id/chromium/network_conditions'],
  set_network_conditions: [:post, 'session/:session_id/chromium/network_conditions'],
  delete_network_conditions: [:delete, 'session/:session_id/chromium/network_conditions'],
  set_permission: [:post, 'session/:session_id/permissions'],
  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



94
95
96
97
# File 'lib/selenium/webdriver/chrome/features.rb', line 94

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

#cast_issue_messageObject



58
59
60
# File 'lib/selenium/webdriver/chrome/features.rb', line 58

def cast_issue_message
  execute :cast_issue_message
end

#cast_sink_to_use=(name) ⇒ Object



54
55
56
# File 'lib/selenium/webdriver/chrome/features.rb', line 54

def cast_sink_to_use=(name)
  execute :set_cast_sink_to_use, {}, {sinkName: name}
end

#cast_sinksObject



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

def cast_sinks
  execute :get_cast_sinks
end

#commands(command) ⇒ Object



42
43
44
# File 'lib/selenium/webdriver/chrome/features.rb', line 42

def commands(command)
  CHROME_COMMANDS[command] || self.class::COMMANDS[command]
end

#delete_network_conditionsObject



86
87
88
# File 'lib/selenium/webdriver/chrome/features.rb', line 86

def delete_network_conditions
  execute :delete_network_conditions
end

#launch_app(id) ⇒ Object



46
47
48
# File 'lib/selenium/webdriver/chrome/features.rb', line 46

def launch_app(id)
  execute :launch_app, {}, {id: id}
end

#log(type) ⇒ Object



99
100
101
102
103
104
105
106
107
# File 'lib/selenium/webdriver/chrome/features.rb', line 99

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

  Array(data).map do |l|
    LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
  rescue KeyError
    next
  end
end

#network_conditionsObject



78
79
80
# File 'lib/selenium/webdriver/chrome/features.rb', line 78

def network_conditions
  execute :get_network_conditions
end

#network_conditions=(conditions) ⇒ Object



82
83
84
# File 'lib/selenium/webdriver/chrome/features.rb', line 82

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

#send_command(command_params) ⇒ Object



90
91
92
# File 'lib/selenium/webdriver/chrome/features.rb', line 90

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

#set_permission(name, value) ⇒ Object



74
75
76
# File 'lib/selenium/webdriver/chrome/features.rb', line 74

def set_permission(name, value)
  execute :set_permission, {}, {descriptor: {name: name}, state: value}
end

#start_cast_desktop_mirroring(name) ⇒ Object



66
67
68
# File 'lib/selenium/webdriver/chrome/features.rb', line 66

def start_cast_desktop_mirroring(name)
  execute :start_cast_desktop_mirroring, {}, {sinkName: name}
end

#start_cast_tab_mirroring(name) ⇒ Object



62
63
64
# File 'lib/selenium/webdriver/chrome/features.rb', line 62

def start_cast_tab_mirroring(name)
  execute :start_cast_tab_mirroring, {}, {sinkName: name}
end

#stop_casting(name) ⇒ Object



70
71
72
# File 'lib/selenium/webdriver/chrome/features.rb', line 70

def stop_casting(name)
  execute :stop_casting, {}, {sinkName: name}
end