{"record":{"id":"587c495c2bb57c13","repo":"SeleniumHQ/selenium","slug":"could-not-find-findelements-js-in-package-pkg","errorCode":null,"errorMessage":"Could not find findElements.js in package {_pkg}","messagePattern":"Could not find findElements\\.js in package (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"py/selenium/webdriver/remote/webdriver.py","lineNumber":934,"sourceCode":"            by: The locating strategy to use. Default is `By.ID`. Supported\n                values include: By.ID, By.NAME, By.XPATH, By.CSS_SELECTOR,\n                By.CLASS_NAME, By.TAG_NAME, By.LINK_TEXT, By.PARTIAL_LINK_TEXT,\n                or RelativeBy.\n            value: The locator value to use with the specified `by` strategy.\n\n        Returns:\n            List of WebElements matching locator strategy found on the page.\n\n        Example:\n            `element = driver.find_elements(By.ID, 'foo')`\n        \"\"\"\n        by, value = self.locator_converter.convert(by, value)\n\n        if isinstance(by, RelativeBy):\n            _pkg = \".\".join(__name__.split(\".\")[:-1])\n            raw_data = pkgutil.get_data(_pkg, \"findElements.js\")\n            if raw_data is None:\n                raise FileNotFoundError(f\"Could not find findElements.js in package {_pkg}\")\n            raw_function = raw_data.decode(\"utf8\")\n            find_element_js = f\"/* findElements */return ({raw_function}).apply(null, arguments);\"\n            return self.execute_script(find_element_js, by.to_dict())\n\n        # Return empty list if driver returns null\n        # See https://github.com/SeleniumHQ/selenium/issues/4555\n        return self.execute(Command.FIND_ELEMENTS, {\"using\": by, \"value\": value})[\"value\"] or []\n\n    @property\n    def capabilities(self) -> dict:\n        \"\"\"Returns the drivers current capabilities being used.\"\"\"\n        return self.caps\n\n    def get_screenshot_as_file(self, filename) -> bool:\n        \"\"\"Save a screenshot of the current window to a PNG image file.\n\n        Returns:\n            False if there is any IOError, else returns True. Use full paths in your filename.","sourceCodeStart":916,"sourceCodeEnd":952,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/py/selenium/webdriver/remote/webdriver.py#L916-L952","documentation":"Raised in `find_elements` (RelativeBY branch) when `pkgutil.get_data(_pkg, 'findElements.js')` returns None — the bundled JS atom that implements relative locators could not be loaded from the package. This is almost always a corrupted/partial install (the file is part of the wheel) rather than caller error. It is a FileNotFoundError.","triggerScenarios":"Calling driver.find_elements(with_tag(...)) on an environment where the selenium package is missing its data files: an incomplete pip install, a broken editable install, a stripped/frozen package that excluded package_data, or running from a source tree without the generated atom.","commonSituations":"Editable installs (pip install -e) missing package_data; PyInstaller/cx_Freeze builds that didn't include *.js data; manually deleting files under site-packages; installing from a partial sdist.","solutions":["Reinstall selenium cleanly: pip install --force-reinstall selenium.","For editable/source checkouts, run the build so atoms are present, then reinstall.","For frozen apps, ensure selenium's package data (*.js) is included by the packager."],"exampleFix":"# before\n# corrupted install; findElements.js missing\ndriver.find_elements(with_tag('button').near(el))\n\n# after (reinstall)\n# pip install --force-reinstall selenium\ndriver.find_elements(with_tag('button').near(el))","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    driver.find_elements(rel_by)\nexcept FileNotFoundError:\n    # selenium package data missing; reinstall selenium and retry","preventionTips":["Install selenium from wheels (pip install selenium) so package_data ships.","When freezing/packaging apps, whitelist selenium data files (*.js).","Don't strip package_data from site-packages to save space."],"tags":["installation","packaging","relative-locator","webdriver"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}