Path: blob/trunk/py/selenium/webdriver/chromium/remote_connection.py
4010 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617from selenium.webdriver.remote.client_config import ClientConfig18from selenium.webdriver.remote.remote_connection import RemoteConnection192021class ChromiumRemoteConnection(RemoteConnection):22def __init__(23self,24remote_server_addr: str,25vendor_prefix: str,26browser_name: str,27keep_alive: bool = True,28ignore_proxy: bool = False,29client_config: ClientConfig | None = None,30) -> None:31client_config = client_config or ClientConfig(32remote_server_addr=remote_server_addr, keep_alive=keep_alive, timeout=12033)34super().__init__(35ignore_proxy=ignore_proxy,36client_config=client_config,37)38self.browser_name = browser_name39commands = self._remote_commands(vendor_prefix)40for key, value in commands.items():41self._commands[key] = value4243def _remote_commands(self, vendor_prefix):44remote_commands = {45"launchApp": ("POST", "/session/$sessionId/chromium/launch_app"),46"setPermissions": ("POST", "/session/$sessionId/permissions"),47"setNetworkConditions": ("POST", "/session/$sessionId/chromium/network_conditions"),48"getNetworkConditions": ("GET", "/session/$sessionId/chromium/network_conditions"),49"deleteNetworkConditions": ("DELETE", "/session/$sessionId/chromium/network_conditions"),50"executeCdpCommand": ("POST", f"/session/$sessionId/{vendor_prefix}/cdp/execute"),51"getSinks": ("GET", f"/session/$sessionId/{vendor_prefix}/cast/get_sinks"),52"getIssueMessage": ("GET", f"/session/$sessionId/{vendor_prefix}/cast/get_issue_message"),53"setSinkToUse": ("POST", f"/session/$sessionId/{vendor_prefix}/cast/set_sink_to_use"),54"startDesktopMirroring": ("POST", f"/session/$sessionId/{vendor_prefix}/cast/start_desktop_mirroring"),55"startTabMirroring": ("POST", f"/session/$sessionId/{vendor_prefix}/cast/start_tab_mirroring"),56"stopCasting": ("POST", f"/session/$sessionId/{vendor_prefix}/cast/stop_casting"),57}58return remote_commands596061