|
17 | 17 | # specific language governing permissions and limitations |
18 | 18 | # under the License. |
19 | 19 |
|
| 20 | +require 'selenium/webdriver/chromium/features' |
| 21 | + |
20 | 22 | module Selenium |
21 | 23 | module WebDriver |
22 | 24 | module Chrome |
23 | 25 | module Features |
24 | 26 |
|
| 27 | + include WebDriver::Chromium::Features |
| 28 | + |
25 | 29 | CHROME_COMMANDS = { |
26 | | - launch_app: [:post, 'session/:session_id/chromium/launch_app'], |
27 | 30 | get_cast_sinks: [:get, 'session/:session_id/goog/cast/get_sinks'], |
28 | 31 | set_cast_sink_to_use: [:post, 'session/:session_id/goog/cast/set_sink_to_use'], |
29 | 32 | start_cast_tab_mirroring: [:post, 'session/:session_id/goog/cast/start_tab_mirroring'], |
30 | 33 | start_cast_desktop_mirroring: [:post, 'session/:session_id/goog/cast/start_desktop_mirroring'], |
31 | 34 | get_cast_issue_message: [:get, 'session/:session_id/goog/cast/get_issue_message'], |
32 | 35 | stop_casting: [:post, 'session/:session_id/goog/cast/stop_casting'], |
33 | | - get_network_conditions: [:get, 'session/:session_id/chromium/network_conditions'], |
34 | | - set_network_conditions: [:post, 'session/:session_id/chromium/network_conditions'], |
35 | | - delete_network_conditions: [:delete, 'session/:session_id/chromium/network_conditions'], |
36 | | - set_permission: [:post, 'session/:session_id/permissions'], |
37 | | - send_command: [:post, 'session/:session_id/goog/cdp/execute'], |
38 | | - get_available_log_types: [:get, 'session/:session_id/se/log/types'], |
39 | | - get_log: [:post, 'session/:session_id/se/log'] |
| 36 | + send_command: [:post, 'session/:session_id/goog/cdp/execute'] |
40 | 37 | }.freeze |
41 | 38 |
|
42 | 39 | def commands(command) |
43 | | - CHROME_COMMANDS[command] || self.class::COMMANDS[command] |
44 | | - end |
45 | | - |
46 | | - def launch_app(id) |
47 | | - execute :launch_app, {}, {id: id} |
48 | | - end |
49 | | - |
50 | | - def cast_sinks |
51 | | - execute :get_cast_sinks |
52 | | - end |
53 | | - |
54 | | - def cast_sink_to_use=(name) |
55 | | - execute :set_cast_sink_to_use, {}, {sinkName: name} |
56 | | - end |
57 | | - |
58 | | - def cast_issue_message |
59 | | - execute :cast_issue_message |
60 | | - end |
61 | | - |
62 | | - def start_cast_tab_mirroring(name) |
63 | | - execute :start_cast_tab_mirroring, {}, {sinkName: name} |
64 | | - end |
65 | | - |
66 | | - def start_cast_desktop_mirroring(name) |
67 | | - execute :start_cast_desktop_mirroring, {}, {sinkName: name} |
68 | | - end |
69 | | - |
70 | | - def stop_casting(name) |
71 | | - execute :stop_casting, {}, {sinkName: name} |
72 | | - end |
73 | | - |
74 | | - def set_permission(name, value) |
75 | | - execute :set_permission, {}, {descriptor: {name: name}, state: value} |
76 | | - end |
77 | | - |
78 | | - def network_conditions |
79 | | - execute :get_network_conditions |
80 | | - end |
81 | | - |
82 | | - def network_conditions=(conditions) |
83 | | - execute :set_network_conditions, {}, {network_conditions: conditions} |
84 | | - end |
85 | | - |
86 | | - def delete_network_conditions |
87 | | - execute :delete_network_conditions |
88 | | - end |
89 | | - |
90 | | - def send_command(command_params) |
91 | | - execute :send_command, {}, command_params |
92 | | - end |
93 | | - |
94 | | - def available_log_types |
95 | | - types = execute :get_available_log_types |
96 | | - Array(types).map(&:to_sym) |
97 | | - end |
98 | | - |
99 | | - def log(type) |
100 | | - data = execute :get_log, {}, {type: type.to_s} |
101 | | - |
102 | | - Array(data).map do |l| |
103 | | - LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message') |
104 | | - rescue KeyError |
105 | | - next |
106 | | - end |
| 40 | + CHROME_COMMANDS[command] || CHROMIUM_COMMANDS[command] || self.class::COMMANDS[command] |
107 | 41 | end |
108 | 42 | end # Bridge |
109 | 43 | end # Chrome |
|
0 commit comments