SeleniumHQ / selenium

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

[🐛 Bug]: selenium.common.exceptions.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 #14206

Closed DendiYoker closed 5 days ago

DendiYoker commented 5 days ago

What happened?

Error

How can we reproduce the issue?

Chrome==126.0.6478.63
Selenium 4.22.0

driver = webdriver.Chrome()
driver.get("http://selenium.dev")

Relevant log output

NFO:selenium:this is useful information
WARNING:selenium:this is a warning
DEBUG:selenium:this is detailed debug information
DEBUG:selenium.webdriver.common.selenium_manager:Selenium Manager binary found at: C:\Users\DYPetrov_bank\PycharmProjects\LocalTest\VENLOCAL\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe
DEBUG:selenium.webdriver.common.selenium_manager:Executing process: C:\Users\DYPetrov_bank\PycharmProjects\LocalTest\VENLOCAL\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser chrome --debug --language-binding python --output json
DEBUG:selenium.webdriver.common.selenium_manager:Sending stats to Plausible: Props { browser: "chrome", browser_version: "", os: "windows", arch: "amd64", lang: "python", selenium_version: "4.22-nightly" }
DEBUG:selenium.webdriver.common.selenium_manager:chromedriver not found in PATH
DEBUG:selenium.webdriver.common.selenium_manager:chrome detected at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
DEBUG:selenium.webdriver.common.selenium_manager:Running command: wmic datafile where name='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe' get Version /value
DEBUG:selenium.webdriver.common.selenium_manager:Output: "\r\r\n\r\r\nVersion=126.0.6478.63\r\r\n\r\r\n\r\r\n\r"
DEBUG:selenium.webdriver.common.selenium_manager:Detected browser: chrome 126.0.6478.63
DEBUG:selenium.webdriver.common.selenium_manager:Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json

Operating System

Windows 10

Selenium version

4.22.0

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

Chrome==126.0.6478.63

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

The driver was not downloaded separately

Are you using Selenium Grid?

Not

github-actions[bot] commented 5 days ago

@DendiYoker, 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!

diemol commented 5 days ago

Can you share the complete log?

DendiYoker commented 5 days ago

Hello.

INFO:selenium:this is useful information
WARNING:selenium:this is a warning
DEBUG:selenium:this is detailed debug information
DEBUG:selenium.webdriver.common.selenium_manager:Selenium Manager binary found at: C:\Users\DYPetrov_bank\PycharmProjects\LocalTest\VENLOCAL\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe
DEBUG:selenium.webdriver.common.selenium_manager:Executing process: C:\Users\DYPetrov_bank\PycharmProjects\LocalTest\VENLOCAL\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser chrome --debug --language-binding python --output json
DEBUG:selenium.webdriver.common.selenium_manager:chromedriver not found in PATH
DEBUG:selenium.webdriver.common.selenium_manager:chrome detected at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
DEBUG:selenium.webdriver.common.selenium_manager:Running command: wmic datafile where name='C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe' get Version /value
DEBUG:selenium.webdriver.common.selenium_manager:Output: "\r\r\n\r\r\nVersion=126.0.6478.63\r\r\n\r\r\n\r\r\n\r"
DEBUG:selenium.webdriver.common.selenium_manager:Detected browser: chrome 126.0.6478.63
DEBUG:selenium.webdriver.common.selenium_manager:Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json
FAILED
test.py:68 (test1)
self = <selenium.webdriver.common.driver_finder.DriverFinder object at 0x05F4FFB8>

    def _binary_paths(self) -> dict:
        if self._paths["driver_path"]:
            return self._paths

        browser = self._options.capabilities["browserName"]
        try:
            path = self._service.path
            if path:
                logger.debug(
                    "Skipping Selenium Manager; path to %s driver specified in Service class: %s", browser, path
                )
                if not Path(path).is_file():
                    raise ValueError(f"The path is not a valid file: {path}")
                self._paths["driver_path"] = path
            else:
>               output = SeleniumManager().binary_paths(self._to_args())

VENLOCAL\lib\site-packages\selenium\webdriver\common\driver_finder.py:67: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.common.selenium_manager.SeleniumManager object at 0x05F97028>
args = ['C:\\Users\\DYPetrov_bank\\PycharmProjects\\LocalTest\\VENLOCAL\\lib\\site-packages\\selenium\\webdriver\\common\\windows\\selenium-manager.exe', '--browser', 'chrome', '--debug', '--language-binding', 'python', ...]

    def binary_paths(self, args: List) -> dict:
        """Determines the locations of the requested assets.

        :Args:
         - args: the commands to send to the selenium manager binary.
        :Returns: dictionary of assets and their path
        """

        args = [str(self._get_binary())] + args
        if logger.getEffectiveLevel() == logging.DEBUG:
            args.append("--debug")
        args.append("--language-binding")
        args.append("python")
        args.append("--output")
        args.append("json")

>       return self._run(args)

VENLOCAL\lib\site-packages\selenium\webdriver\common\selenium_manager.py:53: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ['\\VENLOCAL\\lib\\site-packages\\selenium\\webdriver\\common\\windows\\selenium-manager.exe', '--browser', 'chrome', '--debug', '--language-binding', 'python', ...]

    @staticmethod
    def _run(args: List[str]) -> dict:
        """Executes the Selenium Manager Binary.

        :Args:
         - args: the components of the command being executed.
        :Returns: The log string containing the driver location.
        """
        command = " ".join(args)
        logger.debug("Executing process: %s", command)
        try:
            if sys.platform == "win32":
                completed_proc = subprocess.run(args, capture_output=True, creationflags=subprocess.CREATE_NO_WINDOW)
            else:
                completed_proc = subprocess.run(args, capture_output=True)
            stdout = completed_proc.stdout.decode("utf-8").rstrip("\n")
            stderr = completed_proc.stderr.decode("utf-8").rstrip("\n")
            output = json.loads(stdout) if stdout != "" else {"logs": [], "result": {}}
        except Exception as err:
            raise WebDriverException(f"Unsuccessful command executed: {command}") from err

        SeleniumManager._process_logs(output["logs"])
        result = output["result"]
        if completed_proc.returncode:
>           raise WebDriverException(
                f"Unsuccessful command executed: {command}; code: {completed_proc.returncode}\n{result}\n{stderr}"
            )
E           selenium.common.exceptions.WebDriverException: Message: Unsuccessful command executed: \VENLOCAL\lib\site-packages\selenium\webdriver\common\windows\selenium-manager.exe --browser chrome --debug --language-binding python --output json; code: 65
E           {'code': 65, 'message': 'error sending request for url (https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json)', 'driver_path': '', 'browser_path': ''}

VENLOCAL\lib\site-packages\selenium\webdriver\common\selenium_manager.py:118: WebDriverException

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

set_loger = None

    @allure.feature('pohykakto')
    @my_test('T1')
    def test1(set_loger):
        clear_reports_dir()
        with allure.step(f"{now()}: test_method"):
            Log('')
>           setup_browser()

test.py:75: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
core\tools.py:27: in setup_browser
    driver = webdriver.Chrome()
VENLOCAL\lib\site-packages\selenium\webdriver\chrome\webdriver.py:45: in __init__
    super().__init__(
VENLOCAL\lib\site-packages\selenium\webdriver\chromium\webdriver.py:50: in __init__
    if finder.get_browser_path():
VENLOCAL\lib\site-packages\selenium\webdriver\common\driver_finder.py:47: in get_browser_path
    return self._binary_paths()["browser_path"]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.common.driver_finder.DriverFinder object at 0x05F4FFB8>

    def _binary_paths(self) -> dict:
        if self._paths["driver_path"]:
            return self._paths

        browser = self._options.capabilities["browserName"]
        try:
            path = self._service.path
            if path:
                logger.debug(
                    "Skipping Selenium Manager; path to %s driver specified in Service class: %s", browser, path
                )
                if not Path(path).is_file():
                    raise ValueError(f"The path is not a valid file: {path}")
                self._paths["driver_path"] = path
            else:
                output = SeleniumManager().binary_paths(self._to_args())
                if Path(output["driver_path"]).is_file():
                    self._paths["driver_path"] = output["driver_path"]
                else:
                    raise ValueError(f'The driver path is not a valid file: {output["driver_path"]}')
                if Path(output["browser_path"]).is_file():
                    self._paths["browser_path"] = output["browser_path"]
                else:
                    raise ValueError(f'The browser path is not a valid file: {output["browser_path"]}')
        except Exception as err:
            msg = f"Unable to obtain driver for {browser}"
>           raise NoSuchDriverException(msg) from err
E           selenium.common.exceptions.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

VENLOCAL\lib\site-packages\selenium\webdriver\common\driver_finder.py:78: NoSuchDriverException
diemol commented 5 days ago

Looks like you are behind a proxy, please check this toubleshooting section.

DendiYoker commented 5 days ago

Thank you. I'll try to set it up.