Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/lib/selenium/webdriver/chromium/features.rb
1856 views
1
# frozen_string_literal: true
2
3
# Licensed to the Software Freedom Conservancy (SFC) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The SFC licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
#
11
# http://www.apache.org/licenses/LICENSE-2.0
12
#
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
20
module Selenium
21
module WebDriver
22
module Chromium
23
module Features
24
CHROMIUM_COMMANDS = {
25
launch_app: [:post, 'session/:session_id/chromium/launch_app'],
26
get_network_conditions: [:get, 'session/:session_id/chromium/network_conditions'],
27
set_network_conditions: [:post, 'session/:session_id/chromium/network_conditions'],
28
delete_network_conditions: [:delete, 'session/:session_id/chromium/network_conditions'],
29
set_permission: [:post, 'session/:session_id/permissions'],
30
get_available_log_types: [:get, 'session/:session_id/se/log/types'],
31
get_log: [:post, 'session/:session_id/se/log']
32
}.freeze
33
34
def launch_app(id)
35
execute :launch_app, {}, {id: id}
36
end
37
38
def cast_sinks
39
execute :get_cast_sinks
40
end
41
42
def cast_sink_to_use=(name)
43
execute :set_cast_sink_to_use, {}, {sinkName: name}
44
end
45
46
def cast_issue_message
47
execute :cast_issue_message
48
end
49
50
def start_cast_tab_mirroring(name)
51
execute :start_cast_tab_mirroring, {}, {sinkName: name}
52
end
53
54
def start_cast_desktop_mirroring(name)
55
execute :start_cast_desktop_mirroring, {}, {sinkName: name}
56
end
57
58
def stop_casting(name)
59
execute :stop_casting, {}, {sinkName: name}
60
end
61
62
def set_permission(name, value)
63
execute :set_permission, {}, {descriptor: {name: name}, state: value}
64
end
65
66
def network_conditions
67
execute :get_network_conditions
68
end
69
70
def network_conditions=(conditions)
71
execute :set_network_conditions, {}, {network_conditions: conditions}
72
end
73
74
def delete_network_conditions
75
execute :delete_network_conditions
76
end
77
78
def send_command(command_params)
79
execute :send_command, {}, command_params
80
end
81
82
def available_log_types
83
types = execute :get_available_log_types
84
Array(types).map(&:to_sym)
85
end
86
87
def log(type)
88
data = execute :get_log, {}, {type: type.to_s}
89
90
Array(data).map do |l|
91
LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
92
rescue KeyError
93
next
94
end
95
end
96
end # Bridge
97
end # Chromium
98
end # WebDriver
99
end # Selenium
100
101