Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/selenium/webdriver/chromium/remote_connection.py
4010 views
1
# Licensed to the Software Freedom Conservancy (SFC) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The SFC licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
from selenium.webdriver.remote.client_config import ClientConfig
19
from selenium.webdriver.remote.remote_connection import RemoteConnection
20
21
22
class ChromiumRemoteConnection(RemoteConnection):
23
def __init__(
24
self,
25
remote_server_addr: str,
26
vendor_prefix: str,
27
browser_name: str,
28
keep_alive: bool = True,
29
ignore_proxy: bool = False,
30
client_config: ClientConfig | None = None,
31
) -> None:
32
client_config = client_config or ClientConfig(
33
remote_server_addr=remote_server_addr, keep_alive=keep_alive, timeout=120
34
)
35
super().__init__(
36
ignore_proxy=ignore_proxy,
37
client_config=client_config,
38
)
39
self.browser_name = browser_name
40
commands = self._remote_commands(vendor_prefix)
41
for key, value in commands.items():
42
self._commands[key] = value
43
44
def _remote_commands(self, vendor_prefix):
45
remote_commands = {
46
"launchApp": ("POST", "/session/$sessionId/chromium/launch_app"),
47
"setPermissions": ("POST", "/session/$sessionId/permissions"),
48
"setNetworkConditions": ("POST", "/session/$sessionId/chromium/network_conditions"),
49
"getNetworkConditions": ("GET", "/session/$sessionId/chromium/network_conditions"),
50
"deleteNetworkConditions": ("DELETE", "/session/$sessionId/chromium/network_conditions"),
51
"executeCdpCommand": ("POST", f"/session/$sessionId/{vendor_prefix}/cdp/execute"),
52
"getSinks": ("GET", f"/session/$sessionId/{vendor_prefix}/cast/get_sinks"),
53
"getIssueMessage": ("GET", f"/session/$sessionId/{vendor_prefix}/cast/get_issue_message"),
54
"setSinkToUse": ("POST", f"/session/$sessionId/{vendor_prefix}/cast/set_sink_to_use"),
55
"startDesktopMirroring": ("POST", f"/session/$sessionId/{vendor_prefix}/cast/start_desktop_mirroring"),
56
"startTabMirroring": ("POST", f"/session/$sessionId/{vendor_prefix}/cast/start_tab_mirroring"),
57
"stopCasting": ("POST", f"/session/$sessionId/{vendor_prefix}/cast/stop_casting"),
58
}
59
return remote_commands
60
61