diff --git a/py/selenium/webdriver/common/proxy.py b/py/selenium/webdriver/common/proxy.py index 635785119b8fd..ac0c36b4b71fe 100644 --- a/py/selenium/webdriver/common/proxy.py +++ b/py/selenium/webdriver/common/proxy.py @@ -35,9 +35,8 @@ def load(cls, value): value = value["string"] value = str(value).upper() for attr in dir(cls): - attr_value = getattr(cls, attr) - if isinstance(attr_value, dict) and "string" in attr_value and attr_value["string"] == value: - return attr_value + if getattr(cls, attr) == value: + return value raise Exception(f"No proxy type is found for {value}") @@ -278,7 +277,7 @@ def _verify_proxy_type_compatibility(self, compatible_proxy): def to_capabilities(self): if not self.proxyType: raise ValueError("proxyType must be specified before use") - proxy_caps = {"proxyType": self.proxyType["string"].lower()} + proxy_caps = {"proxyType": self.proxyType.lower()} proxies = [ "autodetect", "ftpProxy", diff --git a/py/test/selenium/webdriver/common/proxy_tests.py b/py/test/selenium/webdriver/common/proxy_tests.py index 3ec0946c874a1..7e748565488a9 100644 --- a/py/test/selenium/webdriver/common/proxy_tests.py +++ b/py/test/selenium/webdriver/common/proxy_tests.py @@ -120,9 +120,9 @@ def test_can_init_pacproxy(): assert PAC_PROXY["proxyAutoconfigUrl"] == proxy.proxy_autoconfig_url -def test_can_init_empty_proxy(): +def test_errors_on_empty_proxy(): proxy = Proxy() - assert ProxyType.UNSPECIFIED == proxy.proxy_type + assert proxy.proxy_type is None assert "" == proxy.http_proxy assert "" == proxy.ftp_proxy assert "" == proxy.no_proxy @@ -135,8 +135,6 @@ def test_can_init_empty_proxy(): assert proxy.socks_version is None options = ArgOptions() - options.proxy = proxy - proxy_capabilities = {} - proxy_capabilities["proxyType"] = "unspecified" - assert proxy_capabilities == options.to_capabilities().get("proxy") + with pytest.raises(ValueError): + options.proxy = proxy