Skip to content

Commit

Permalink
fix python errors
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Dec 12, 2023
1 parent 54bead8 commit feaa53c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
7 changes: 3 additions & 4 deletions py/selenium/webdriver/common/proxy.py
Expand Up @@ -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}")


Expand Down Expand Up @@ -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",
Expand Down
10 changes: 4 additions & 6 deletions py/test/selenium/webdriver/common/proxy_tests.py
Expand Up @@ -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
Expand All @@ -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

0 comments on commit feaa53c

Please sign in to comment.