MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / get_remote_connection

Function get_remote_connection

py/selenium/webdriver/remote/webdriver.py:167–210  ·  view source on GitHub ↗
(
    capabilities: dict,
    command_executor: str | RemoteConnection,
    keep_alive: bool,
    ignore_local_proxy: bool,
    client_config: ClientConfig | None = None,
)

Source from the content-addressed store, hash-verified

165
166
167def get_remote_connection(
168 capabilities: dict,
169 command_executor: str | RemoteConnection,
170 keep_alive: bool,
171 ignore_local_proxy: bool,
172 client_config: ClientConfig | None = None,
173) -> RemoteConnection:
174 if isinstance(command_executor, str):
175 client_config = client_config or ClientConfig(remote_server_addr=command_executor)
176 client_config.remote_server_addr = command_executor
177 command_executor = RemoteConnection(client_config=client_config)
178
179 browser_name = capabilities.get("browserName")
180 handler: type[RemoteConnection]
181 if browser_name == "chrome":
182 from selenium.webdriver.chrome.remote_connection import ChromeRemoteConnection
183
184 handler = ChromeRemoteConnection
185 elif browser_name in ("MicrosoftEdge", "webview2"):
186 from selenium.webdriver.edge.remote_connection import EdgeRemoteConnection
187
188 handler = EdgeRemoteConnection
189 elif browser_name == "firefox":
190 from selenium.webdriver.firefox.remote_connection import FirefoxRemoteConnection
191
192 handler = FirefoxRemoteConnection
193 elif browser_name in ("safari", "Safari Technology Preview"):
194 from selenium.webdriver.safari.remote_connection import SafariRemoteConnection
195
196 handler = SafariRemoteConnection
197 else:
198 handler = RemoteConnection
199
200 if hasattr(command_executor, "client_config") and command_executor.client_config:
201 remote_server_addr = command_executor.client_config.remote_server_addr
202 else:
203 remote_server_addr = command_executor
204
205 return handler(
206 remote_server_addr=remote_server_addr,
207 keep_alive=keep_alive,
208 ignore_proxy=ignore_local_proxy,
209 client_config=client_config,
210 )
211
212
213def create_matches(options: list[BaseOptions]) -> dict:

Calls 4

ClientConfigClass · 0.90
RemoteConnectionClass · 0.90
getMethod · 0.65
handlerFunction · 0.50