{"record":{"id":"23dbc7a3942b298c","repo":"SeleniumHQ/selenium","slug":"port-needs-to-be-an-integer","errorCode":null,"errorMessage":"Port needs to be an integer","messagePattern":"Port needs to be an integer","errorType":"exception","errorClass":"WebDriverException","httpStatus":null,"severity":"warning","filePath":"py/selenium/webdriver/firefox/firefox_profile.py","lineNumber":113,"sourceCode":"    # Properties\n\n    @property\n    def path(self):\n        \"\"\"Gets the profile directory that is currently being used.\"\"\"\n        return self._profile_dir\n\n    @property\n    @deprecated(\"The port is stored in the Service class\")\n    def port(self):\n        \"\"\"Gets the port that WebDriver is working on.\"\"\"\n        return self._port\n\n    @port.setter\n    @deprecated(\"The port is stored in the Service class\")\n    def port(self, port) -> None:\n        \"\"\"Sets the port that WebDriver will be running on.\"\"\"\n        if not isinstance(port, int):\n            raise WebDriverException(\"Port needs to be an integer\")\n        try:\n            port = int(port)\n            if port < 1 or port > 65535:\n                raise WebDriverException(\"Port number must be in the range 1..65535\")\n        except (ValueError, TypeError):\n            raise WebDriverException(\"Port needs to be an integer\")\n        self._port = port\n        self.set_preference(\"webdriver_firefox_port\", self._port)\n\n    @property\n    @deprecated(\"Allowing untrusted certs is toggled in the Options class\")\n    def accept_untrusted_certs(self):\n        return self._desired_preferences[\"webdriver_accept_untrusted_certs\"]\n\n    @accept_untrusted_certs.setter\n    @deprecated(\"Allowing untrusted certs is toggled in the Options class\")\n    def accept_untrusted_certs(self, value) -> None:\n        if not isinstance(value, bool):","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/firefox/firefox_profile.py#L95-L131","documentation":"Raised by the (deprecated) FirefoxProfile.port setter when the value is not an int. This is the first guard in the setter; it rejects non-int types outright before attempting any range or coercion logic. The entire port property is deprecated — port should be set on the Firefox Service, not the profile.","triggerScenarios":"Assigning profile.port = '7042' or profile.port = 7042.0 (a float) triggers this immediately because isinstance(port, int) is False for strings and floats. Note: a bool would pass this check (bool is a subclass of int) but then fail range validation.","commonSituations":"Using legacy code or examples that set profile.port, passing a value parsed from config as a string, or migrating old Selenium 3 code. The deprecation warning should already steer users away.","solutions":["Stop using profile.port — set the port on the Firefox Service instead: Service(port=7042).","If you must use the deprecated API, pass an int: profile.port = 7042.","Convert config values to int before assignment: profile.port = int(value)."],"exampleFix":"# before (deprecated path)\nprofile = FirefoxProfile()\nprofile.port = '7042'  # -> WebDriverException\n\n# after — set port on the Service\nfrom selenium.webdriver.firefox.service import Service\nservice = Service(port=7042)\ndriver = webdriver.Firefox(service=service)","handlingStrategy":"type-guard","validationCode":"assert isinstance(port, int) and not isinstance(port, bool), 'port must be a plain int'\nprofile.port = port","typeGuard":"def is_plain_int(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool)","tryCatchPattern":"from selenium.common.exceptions import WebDriverException\ntry:\n    profile.port = raw\nexcept WebDriverException:\n    profile.port = int(raw)","preventionTips":["Prefer setting port on the Firefox Service instead of the deprecated profile.port.","Coerce config strings to int before assignment.","Treat any use of profile.port as legacy code to migrate."],"tags":["firefox","profile","deprecated","type-validation","configuration"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}