{"record":{"id":"e6efa4243ec31a9f","repo":"SeleniumHQ/selenium","slug":"only-proxy-objects-can-be-passed-in","errorCode":null,"errorMessage":"Only Proxy objects can be passed in.","messagePattern":"Only Proxy objects can be passed in\\.","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/common/options.py","lineNumber":159,"sourceCode":"            raise ValueError(\"Timeout keys can only be one of the following: implicit, pageLoad, script\")\n\n\nclass _ProxyDescriptor:\n    \"\"\"Descriptor for proxy property access.\n\n    Returns:\n        Proxy if set, otherwise None.\n    \"\"\"\n\n    def __init__(self, name):\n        self.name = name\n\n    def __get__(self, obj, cls):\n        return obj._proxy\n\n    def __set__(self, obj, value):\n        if not isinstance(value, Proxy):\n            raise InvalidArgumentException(\"Only Proxy objects can be passed in.\")\n        obj._proxy = value\n        obj._caps[self.name] = value.to_capabilities()\n\n\nclass BaseOptions(metaclass=ABCMeta):\n    \"\"\"Base class for individual browser options.\"\"\"\n\n    browser_version = _BaseOptionsDescriptor(\"browserVersion\")\n    \"\"\"Gets and Sets the version of the browser.\n\n    Usage:\n        - Get: `self.browser_version`\n        - Set: `self.browser_version = value`\n\n    Args:\n        value: str\n\n    Returns:","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/common/options.py#L141-L177","documentation":"The proxy property on Options only accepts an instance of selenium.webdriver.common.proxy.Proxy. Passing a dict, a string, or any other type raises InvalidArgumentException. The setter both stores the Proxy and writes its capabilities into the options' caps.","triggerScenarios":"Assigning options.proxy = {'httpProxy': 'host:8080'} (a raw dict) instead of a Proxy object. Passing a URL string. Passing None after a Proxy was set also fails the isinstance check.","commonSituations":"Reading proxy config from JSON/env as a dict and assigning it directly. Assuming the setter accepts the same shape as capabilities. Migrating from older code that used raw dicts.","solutions":["Construct a Proxy first, then assign: options.proxy = Proxy({'httpProxy': 'host:8080'}).","Configure the Proxy via its properties (proxy.http_proxy = ...) before assigning."],"exampleFix":"# before\noptions.proxy = {'httpProxy': 'localhost:8080'}  # raises InvalidArgumentException\n\n# after\nfrom selenium.webdriver.common.proxy import Proxy, ProxyType\np = Proxy({'httpProxy': 'localhost:8080'})\np.proxy_type = ProxyType.MANUAL\noptions.proxy = p","handlingStrategy":"type-guard","validationCode":"from selenium.webdriver.common.proxy import Proxy\nif not isinstance(proxy_value, Proxy):\n    proxy_value = Proxy(proxy_value) if isinstance(proxy_value, dict) else Proxy()\noptions.proxy = proxy_value","typeGuard":"from selenium.webdriver.common.proxy import Proxy\ndef is_proxy(v) -> bool:\n    return isinstance(v, Proxy)","tryCatchPattern":"from selenium.common.exceptions import InvalidArgumentException\ntry:\n    options.proxy = value\nexcept InvalidArgumentException:\n    options.proxy = Proxy(value) if isinstance(value, dict) else Proxy()","preventionTips":["Always wrap raw proxy dicts in Proxy(...) before assigning.","Construct and configure a single Proxy object in your config layer."],"tags":["options","proxy","type-validation","capabilities"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}