Skip to content

Commit 3a3c46b

Browse files
authored
[py] Add backward compatibility for AppiumConnection (#14696)
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent bdfbb70 commit 3a3c46b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Diff for: py/selenium/webdriver/remote/remote_connection.py

+15
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ class RemoteConnection:
136136
"""
137137

138138
browser_name = None
139+
# Keep backward compatibility for AppiumConnection - https://github.com/SeleniumHQ/selenium/issues/14694
140+
import os
141+
import socket
142+
143+
import certifi
144+
145+
_timeout = (
146+
float(os.getenv("GLOBAL_DEFAULT_TIMEOUT", str(socket.getdefaulttimeout())))
147+
if os.getenv("GLOBAL_DEFAULT_TIMEOUT") is not None
148+
else socket.getdefaulttimeout()
149+
)
150+
_ca_certs = os.getenv("REQUESTS_CA_BUNDLE") if "REQUESTS_CA_BUNDLE" in os.environ else certifi.where()
139151
_client_config: ClientConfig = None
140152

141153
system = platform.system().lower()
@@ -296,6 +308,9 @@ def __init__(
296308
init_args_for_pool_manager=init_args_for_pool_manager,
297309
)
298310

311+
# Keep backward compatibility for AppiumConnection - https://github.com/SeleniumHQ/selenium/issues/14694
312+
RemoteConnection._timeout = self._client_config.timeout
313+
RemoteConnection._ca_certs = self._client_config.ca_certs
299314
RemoteConnection._client_config = self._client_config
300315

301316
if remote_server_addr:

Diff for: py/test/unit/selenium/webdriver/remote/remote_connection_tests.py

+13
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,19 @@ def test_register_extra_headers(mock_request, remote_connection):
307307
assert headers["Foo"] == "bar"
308308

309309

310+
def test_backwards_compatibility_with_appium_connection():
311+
# Keep backward compatibility for AppiumConnection - https://github.com/SeleniumHQ/selenium/issues/14694
312+
client_config = ClientConfig(remote_server_addr="http://remote", ca_certs="/path/to/cacert.pem", timeout=300)
313+
remote_connection = RemoteConnection(client_config=client_config)
314+
assert remote_connection._ca_certs == "/path/to/cacert.pem"
315+
assert remote_connection._timeout == 300
316+
assert remote_connection._client_config == client_config
317+
remote_connection.set_timeout(120)
318+
assert remote_connection.get_timeout() == 120
319+
remote_connection.set_certificate_bundle_path("/path/to/cacert2.pem")
320+
assert remote_connection.get_certificate_bundle_path() == "/path/to/cacert2.pem"
321+
322+
310323
def test_get_connection_manager_with_timeout_from_client_config():
311324
remote_connection = RemoteConnection(remote_server_addr="http://remote", keep_alive=False)
312325
remote_connection.set_timeout(10)

0 commit comments

Comments
 (0)