SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
29.78k stars 8.02k forks source link

[๐Ÿ› Bug]: Unable to obtain driver for chrome #14069

Closed Redas17 closed 1 month ago

Redas17 commented 1 month ago

What happened?

Hello, just trying to run this simple code and get bunch of errors. I tried to remove from selenium.webdriver.common.by import By or add "service" thing, same result, I added chromedriver to the system Path, but it didn't resolve the issue, help is appreciated.

How can we reproduce the issue?

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://google.com")

Relevant log output

WebDriverException                        Traceback (most recent call last)
File ~\anaconda3\envs\env39\lib\site-packages\selenium\webdriver\common\driver_finder.py:67, in DriverFinder._binary_paths(self)
     66 else:
---> 67     output = SeleniumManager().binary_paths(self._to_args())
     68     if Path(output["driver_path"]).is_file():

File ~\anaconda3\envs\env39\lib\site-packages\selenium\webdriver\common\selenium_manager.py:45, in SeleniumManager.binary_paths(self, args)
     38 """Determines the locations of the requested assets.
     39 
     40 :Args:
     41  - args: the commands to send to the selenium manager binary.
     42 :Returns: dictionary of assets and their path
     43 """
---> 45 args = [str(self._get_binary())] + args
     46 if logger.getEffectiveLevel() == logging.DEBUG:

File ~\anaconda3\envs\env39\lib\site-packages\selenium\webdriver\common\selenium_manager.py:88, in SeleniumManager._get_binary()
     87 if not path.is_file():
---> 88     raise WebDriverException(f"Unable to obtain working Selenium Manager binary; {path}")
     90 logger.debug("Selenium Manager binary found at: %s", path)

WebDriverException: Message: Unable to obtain working Selenium Manager binary; C:\Users\Home\anaconda3\envs\env39\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe

The above exception was the direct cause of the following exception:

NoSuchDriverException                     Traceback (most recent call last)
Cell In[4], line 4
      1 from selenium import webdriver
----> 4 driver = webdriver.Chrome()
      5 driver.get("https://google.com")

File ~\anaconda3\envs\env39\lib\site-packages\selenium\webdriver\chrome\webdriver.py:45, in WebDriver.__init__(self, options, service, keep_alive)
     42 service = service if service else Service()
     43 options = options if options else Options()
---> 45 super().__init__(
     46     browser_name=DesiredCapabilities.CHROME["browserName"],
     47     vendor_prefix="goog",
     48     options=options,
     49     service=service,
     50     keep_alive=keep_alive,
     51 )

File ~\anaconda3\envs\env39\lib\site-packages\selenium\webdriver\chromium\webdriver.py:50, in ChromiumDriver.__init__(self, browser_name, vendor_prefix, options, service, keep_alive)
     47 self.service = service
     49 finder = DriverFinder(self.service, options)
---> 50 if finder.get_browser_path():
     51     options.binary_location = finder.get_browser_path()
     52     options.browser_version = None

File ~\anaconda3\envs\env39\lib\site-packages\selenium\webdriver\common\driver_finder.py:47, in DriverFinder.get_browser_path(self)
     46 def get_browser_path(self) -> str:
---> 47     return self._binary_paths()["browser_path"]

File ~\anaconda3\envs\env39\lib\site-packages\selenium\webdriver\common\driver_finder.py:78, in DriverFinder._binary_paths(self)
     76 except Exception as err:
     77     msg = f"Unable to obtain driver for {browser}"
---> 78     raise NoSuchDriverException(msg) from err
     79 return self._paths

NoSuchDriverException: Message: Unable to obtain driver for chrome; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

Operating System

Windows 10

Selenium version

Python 3.10

What are the browser(s) and version(s) where you see this issue?

Chrome 142

What are the browser driver(s) and version(s) where you see this issue?

Chrome 141

Are you using Selenium Grid?

4.21

github-actions[bot] commented 1 month ago

@Redas17, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

titusfortner commented 1 month ago

This is an issue with anaconda. Read the section on custom package managers here https://www.selenium.dev/documentation/selenium_manager/

github-actions[bot] commented 1 day ago

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.