Path: blob/trunk/py/selenium/webdriver/chromium/remote_connection.py
1864 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.16from typing import Optional1718from selenium.webdriver.remote.client_config import ClientConfig19from selenium.webdriver.remote.remote_connection import RemoteConnection202122class ChromiumRemoteConnection(RemoteConnection):23def __init__(24self,25remote_server_addr: str,26vendor_prefix: str,27browser_name: str,28keep_alive: bool = True,29ignore_proxy: Optional[bool] = False,30client_config: Optional[ClientConfig] = None,31) -> None:32client_config = client_config or ClientConfig(33remote_server_addr=remote_server_addr, keep_alive=keep_alive, timeout=12034)35super().__init__(36ignore_proxy=ignore_proxy,37client_config=client_config,38)39self.browser_name = browser_name40commands = self._remote_commands(vendor_prefix)41for key, value in commands.items():42self._commands[key] = value4344def _remote_commands(self, vendor_prefix):45remote_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}59return remote_commands606162