{"record":{"id":"57f2809c923ceac8","repo":"SeleniumHQ/selenium","slug":"you-must-enable-downloads-in-order-to-work-with-do","errorCode":null,"errorMessage":"You must enable downloads in order to work with downloadable files.","messagePattern":"You must enable downloads in order to work with downloadable files\\.","errorType":"exception","errorClass":"WebDriverException","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/remote/webdriver.py","lineNumber":1562,"sourceCode":"    def set_user_verified(self, verified: bool) -> None:\n        \"\"\"Set whether the authenticator will simulate success or failure on user verification.\n\n        Args:\n            verified: True if the authenticator will pass user verification,\n                False otherwise.\n\n        Example:\n            `driver.set_user_verified(True)`\n        \"\"\"\n        self.execute(\n            Command.SET_USER_VERIFIED,\n            {\"authenticatorId\": self._authenticator_id, \"isUserVerified\": verified},\n        )\n\n    def get_downloadable_files(self) -> list:\n        \"\"\"Retrieves the downloadable files as a list of file names.\"\"\"\n        if \"se:downloadsEnabled\" not in self.capabilities:\n            raise WebDriverException(\"You must enable downloads in order to work with downloadable files.\")\n\n        return self.execute(Command.GET_DOWNLOADABLE_FILES)[\"value\"][\"names\"]\n\n    def download_file(self, file_name: str, target_directory: str) -> None:\n        \"\"\"Download a file with the specified file name to the target directory.\n\n        Args:\n            file_name: The name of the file to download.\n            target_directory: The path to the directory to save the downloaded file.\n\n        Example:\n            `driver.download_file(\"example.zip\", \"/path/to/directory\")`\n        \"\"\"\n        if \"se:downloadsEnabled\" not in self.capabilities:\n            raise WebDriverException(\"You must enable downloads in order to work with downloadable files.\")\n\n        if not os.path.exists(target_directory):\n            os.makedirs(target_directory)","sourceCodeStart":1544,"sourceCodeEnd":1580,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/remote/webdriver.py#L1544-L1580","documentation":"Raised by get_downloadable_files() when 'se:downloadsEnabled' is not present in the session capabilities. Selenium's downloadable-files feature requires the server to opt in at session creation (it must hold files server-side), so the client gates every download API on this capability flag. Without it, the call is meaningless.","triggerScenarios":"Calling driver.get_downloadable_files() on a session created without enabling downloads. The check is a simple `if 'se:downloadsEnabled' not in self.capabilities`.","commonSituations":"Default driver sessions do not enable the downloads capability. A developer tries to fetch a file list after triggering a browser download, forgetting the session was not opted in.","solutions":["Enable downloads at session creation: options.set_capability('se:downloads', True) before instantiating the driver.","Confirm the remote server is Selenium 4.x+ and supports the se:downloads capability.","Re-create the session with downloads enabled rather than trying to toggle it mid-session."],"exampleFix":"# before\noptions = webdriver.ChromeOptions()\ndriver = webdriver.Chrome(options=options)\ndriver.get_downloadable_files()  # raises\n\n# after\noptions = webdriver.ChromeOptions()\noptions.set_capability('se:downloads', True)\ndriver = webdriver.Chrome(options=options)","handlingStrategy":"validation","validationCode":"if 'se:downloadsEnabled' not in driver.capabilities:\n    raise RuntimeError('Enable downloads: options.set_capability(\"se:downloads\", True) at startup')\ndriver.get_downloadable_files()","typeGuard":"def downloads_enabled(driver) -> bool:\n    return 'se:downloadsEnabled' in driver.capabilities","tryCatchPattern":"from selenium.common.exceptions import WebDriverException\ntry:\n    files = driver.get_downloadable_files()\nexcept WebDriverException:\n    files = []  # downloads not enabled for this session","preventionTips":["Set options.set_capability('se:downloads', True) when you need server-side downloads.","Guard all download calls with a capability check.","Use a Selenium 4.x+ server that supports the capability."],"tags":["downloads","capabilities","files"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}