{"record":{"id":"2bd2ec96f36a653f","repo":"crewAIInc/crewAI","slug":"url-cannot-be-empty","errorCode":null,"errorMessage":"URL cannot be empty","messagePattern":"URL cannot be empty","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/selenium_scraping_tool/selenium_scraping_tool.py","lineNumber":193,"sourceCode":"    def _get_elements_content(\n        self, css_element: str | None, return_html: bool | None\n    ) -> list[str]:\n        if self.driver is None or self._by is None:\n            raise RuntimeError(\"Driver not initialized. Call _run first.\")\n        elements_content: list[str] = []\n\n        for element in self.driver.find_elements(self._by.CSS_SELECTOR, css_element):\n            elements_content.append(  # noqa: PERF401\n                element.get_attribute(\"outerHTML\") if return_html else element.text\n            )\n\n        return elements_content\n\n    def _make_request(\n        self, url: str | None, cookie: dict[str, Any] | None, wait_time: int | None\n    ) -> None:\n        if not url:\n            raise ValueError(\"URL cannot be empty\")\n\n        if not re.match(r\"^https?://\", url):\n            raise ValueError(\"URL must start with http:// or https://\")\n\n        if self.driver is None:\n            raise RuntimeError(\"Driver not initialized. Call _run first.\")\n        sleep_time = wait_time or 0\n        self.driver.get(url)\n        time.sleep(sleep_time)\n        if cookie:\n            self.driver.add_cookie(cookie)\n            time.sleep(sleep_time)\n            self.driver.get(url)\n            time.sleep(sleep_time)\n\n    def close(self) -> None:\n        if self.driver is not None:\n            self.driver.close()","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/selenium_scraping_tool/selenium_scraping_tool.py#L175-L211","documentation":"ValueError raised by SeleniumScrapingTool._make_request when the url argument is falsy (None or empty string). _make_request is the navigation step of _run; the schema validator already blocks empty URLs at construction, so this guard mainly catches the code path where _run was called without a website_url and the internal default is unset. It fails before the browser navigates anywhere.","triggerScenarios":"Calling the tool with no website_url provided anywhere (neither constructor nor run kwargs) so _make_request receives None; internal/direct calls to _make_request with an empty url.","commonSituations":"Instantiating SeleniumScrapingTool() bare and calling run() expecting the agent to always supply the URL, but it doesn't; dynamic flows where the URL variable is conditionally assigned and ends up None.","solutions":["Pass the URL: SeleniumScrapingTool(website_url='https://example.com', css_element='article') or tool.run('https://example.com').","Default the URL variable early: url = url or FALLBACK_URL before invoking the tool.","Fail fast in your orchestration code when a required URL is missing."],"exampleFix":"# before\nresult = tool.run()  # no url anywhere -> ValueError: URL cannot be empty\n\n# after\nresult = tool.run(\"https://example.com\")","handlingStrategy":"validation","validationCode":"if not url or not url.strip():\n    raise ValueError(\"a website_url must be supplied to SeleniumScrapingTool\")\nresult = tool.run(url.strip())","typeGuard":null,"tryCatchPattern":"try:\n    result = tool.run()\nexcept ValueError as e:\n    if \"cannot be empty\" in str(e):\n        result = tool.run(DEFAULT_URL)\n    else:\n        raise","preventionTips":["Always supply website_url at construction or at call time.","Default optional URL variables explicitly instead of letting None flow into the tool."],"tags":["validation","selenium","url","required-argument"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}