Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py] Add backward compatibility for AppiumConnection #14696

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ class RemoteConnection:
"""

browser_name = None
# Keep backward compatibility for AppiumConnection - https://github.com/SeleniumHQ/selenium/issues/14694
import os
import socket

import certifi

_timeout = (
float(os.getenv("GLOBAL_DEFAULT_TIMEOUT", str(socket.getdefaulttimeout())))
if os.getenv("GLOBAL_DEFAULT_TIMEOUT") is not None
else socket.getdefaulttimeout()
)
_ca_certs = os.getenv("REQUESTS_CA_BUNDLE") if "REQUESTS_CA_BUNDLE" in os.environ else certifi.where()
_client_config: ClientConfig = None

system = platform.system().lower()
Expand Down Expand Up @@ -296,6 +308,9 @@ def __init__(
init_args_for_pool_manager=init_args_for_pool_manager,
)

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

if remote_server_addr:
Expand Down
13 changes: 13 additions & 0 deletions py/test/unit/selenium/webdriver/remote/remote_connection_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,19 @@ def test_register_extra_headers(mock_request, remote_connection):
assert headers["Foo"] == "bar"


def test_backwards_compatibility_with_appium_connection():
# Keep backward compatibility for AppiumConnection - https://github.com/SeleniumHQ/selenium/issues/14694
client_config = ClientConfig(remote_server_addr="http://remote", ca_certs="/path/to/cacert.pem", timeout=300)
remote_connection = RemoteConnection(client_config=client_config)
assert remote_connection._ca_certs == "/path/to/cacert.pem"
assert remote_connection._timeout == 300
assert remote_connection._client_config == client_config
remote_connection.set_timeout(120)
assert remote_connection.get_timeout() == 120
remote_connection.set_certificate_bundle_path("/path/to/cacert2.pem")
assert remote_connection.get_certificate_bundle_path() == "/path/to/cacert2.pem"


def test_get_connection_manager_with_timeout_from_client_config():
remote_connection = RemoteConnection(remote_server_addr="http://remote", keep_alive=False)
remote_connection.set_timeout(10)
Expand Down
Loading