Skip to content

ChromeDriver.install() bug #649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Rsalganik1123 opened this issue Dec 19, 2023 · 19 comments
Closed

ChromeDriver.install() bug #649

Rsalganik1123 opened this issue Dec 19, 2023 · 19 comments

Comments

@Rsalganik1123
Copy link

When trying to replicate the ChromeDriver example in the documentation, I get the following error : AttributeError: 'NoneType' object has no attribute 'split'

To reproduce:

from selenium import webdriver
from selenium.common import NoSuchElementException
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())

Used to work but suddenly doesn't -- maybe there was some update I'm not aware of?

@misterpip
Copy link

same issue here

@deKeijzer
Copy link

deKeijzer commented Dec 28, 2023

Something similar here with a slightly different error. On my Mac M3 I get the following error.

WebDriverException: Message: Service /Users/briandekeijzer/.wdm/drivers/chromedriver/mac64/119.0.6045.105/chromedriver-mac-arm64/chromedriver unexpectedly exited. Status code was: -9

I fixed this a couple of days ago by reinstalling selenium and webdriver_manager through pip. But for some reason the error is back. My env has not changed. Running the same fix doesn't resolve the issue.

To reproduce use:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))

On Python 3.9 with selenium version 4.16.0 and webdriver-manager version 4.0.1.

Edit:

A temporary fix is to remove the .wdm folder and --upgrade the package.

rm -rf /Users/briandekeijzer/.wdm
pip install --upgrade webdriver_manager

@anonhostpi
Copy link

Likely culprit:

It looks like webdriver manager can't resolve the webdriver path.

This likely means one of 3 things, it can't find chrome, it can't find chromedriver, or it can't map the correct version of chrome to the correct version of chromedriver.

@vorenhoutgithub
Copy link

Traceback

2024-01-14 18:38:15     driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
2024-01-14 18:38:15                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-14 18:38:15   File "/usr/local/lib/python3.11/site-packages/webdriver_manager/chrome.py", line 40, in install
2024-01-14 18:38:15     driver_path = self._get_driver_binary_path(self.driver)
2024-01-14 18:38:15                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-14 18:38:15   File "/usr/local/lib/python3.11/site-packages/webdriver_manager/core/manager.py", line 40, in _get_driver_binary_path
2024-01-14 18:38:15     file = self._download_manager.download_file(driver.get_driver_download_url(os_type))
2024-01-14 18:38:15                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-14 18:38:15   File "/usr/local/lib/python3.11/site-packages/webdriver_manager/drivers/chrome.py", line 32, in get_driver_download_url
2024-01-14 18:38:15     driver_version_to_download = self.get_driver_version_to_download()
2024-01-14 18:38:15                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-14 18:38:15   File "/usr/local/lib/python3.11/site-packages/webdriver_manager/core/driver.py", line 48, in get_driver_version_to_download
2024-01-14 18:38:15     return self.get_latest_release_version()
2024-01-14 18:38:15            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-14 18:38:15   File "/usr/local/lib/python3.11/site-packages/webdriver_manager/drivers/chrome.py", line 64, in get_latest_release_version
2024-01-14 18:38:15     determined_browser_version = ".".join(determined_browser_version.split(".")[:3])
2024-01-14 18:38:15                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-01-14 18:38:15 AttributeError: 'NoneType' object has no attribute 'split'

@Lyapsus
Copy link

Lyapsus commented Jan 15, 2024

image

@MarcBresson
Copy link
Contributor

MarcBresson commented Jan 16, 2024

I don't see how this code was ever able to work. Is it required for chrome to be installed?

in https://github.com/SergeyPirogov/webdriver_manager/blob/master/webdriver_manager/drivers/chrome.py#L54

        determined_browser_version = self.get_browser_version_from_os()
        log(f"Get LATEST {self._name} version for {self._browser_type}")
        if determined_browser_version is not None and version.parse(determined_browser_version) >= version.parse("115"):
            ...
            return determined_browser_version

        # at this point, determined_browser_version can be None if chrome is not installed, so splitting cannot work
        determined_browser_version = ".".join(determined_browser_version.split(".")[:3])
        latest_release_url = (
            self._latest_release_url
            if (determined_browser_version is None)
            else f"{self._latest_release_url}_{determined_browser_version}"
        )

I am creating a PR right away

@oezeb
Copy link

oezeb commented Jan 31, 2024

Same problem here

Pwuts added a commit to Significant-Gravitas/AutoGPT that referenced this issue Feb 20, 2024
…ails

We have been seeing `AttributeError: 'NoneType' object has no attribute 'split'` in Sentry.
According to SergeyPirogov/webdriver_manager#649, this occurs
when Chrome is not installed, or when no suitable ChromeDriver version is available for
the installed version of Chrome.
Instead of the `AttributeError`, we can print a better message for the agent and user to help them fix the issue.

---
Co-authored-by: kcze <[email protected]>
@wilsonsdev
Copy link

Temporary solution is to install the webdriver manually
for ubuntu: sudo apt install chromium-driver

@junekhan
Copy link

junekhan commented Apr 3, 2024

Temporary solution is to install the webdriver manually for ubuntu: sudo apt install chromium-driver

This doesn't work for me. I alternatively installed a full-sized chrome with sudo apt install chromium.

@anonhostpi
Copy link

anonhostpi commented Apr 4, 2024

Temporary solution is to install the webdriver manually for ubuntu: sudo apt install chromium-driver

This doesn't work for me. I alternatively installed a full-sized chrome with sudo apt install chromium.

Yeah that's the bug. I think when this repository was originally designed, it was designed with local instances of browsers in mind, and not remote browsers/browser-servers. So, with the original design, you had to have a local installation available.

@nrmiller5
Copy link

I am having this same issue except I am attempting to run some scraping with Selenium in MWAA. Does anyone have any tips on how I could resolve it there?

@kmahorker
Copy link

I was running into this issue when using webdriver_manager in Python 3.

Solution:

  1. Get chromedriver with sudo apt install chromium-driver
  2. Skip the install and specify the Service path directly:
chromedriver_path = '/usr/bin/chromedriver' # or wherever chromedriver is installed for you
driver = webdriver.Chrome(options=options, service=Service(chromedriver_path))

For context this was the problematic code before running into the same issues others cited above:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager

options = Options()
options.headless = args.headless
driver = webdriver.Chrome(
    options=options, service=Service(ChromeDriverManager().install())
)

@LagSlug
Copy link

LagSlug commented Apr 10, 2024

The simplest fix for this is just to set the driver_version, I set mine to "120" and the download worked fine. It looks like the OperationSystemManager class is unable to identify the most recent version of chrome.

def get_latest_release_version(self):
        determined_browser_version = self.get_browser_version_from_os()
        log(f"Get LATEST {self._name} version for {self._browser_type}")
        if determined_browser_version is not None and version.parse(determined_browser_version) >= version.parse("115"):
            url = "https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build.json"
            response = self._http_client.get(url)
            response_dict = json.loads(response.text)
            determined_browser_version = response_dict.get("builds").get(determined_browser_version).get("version")
            return determined_browser_version
        # Remove the build version (the last segment) from determined_browser_version for version < 113
        determined_browser_version = ".".join(determined_browser_version.split(".")[:3])
        latest_release_url = (
            self._latest_release_url
            if (determined_browser_version is None)
            else f"{self._latest_release_url}_{determined_browser_version}"
        )
        resp = self._http_client.get(url=latest_release_url)
        return resp.text.rstrip()

I think it would be a good idea to check that determined_browser_version isn't None before being split, and just set it to a hard coded default value if it is. Or it might even better better to fix upstream in get_browser_version_from_os, and make that return a hard coded default value.

Solution:

    from webdriver_manager.chrome import ChromeDriverManager
    print(ChromeDriverManager(driver_version='120').install())

@joon612
Copy link

joon612 commented May 27, 2024

Same issue here.
Environment:
Windows 11
Python 3.9.17
Webdriver_manager 4.0.1

error msgs:

'powershell' is not recognized as an internal or external command,
operable program or batch file.
'powershell' is not recognized as an internal or external command,
operable program or batch file.
'powershell' is not recognized as an internal or external command,
operable program or batch file.
...
  File "c:\Users\username\AppData\Local\miniconda3\envs\env\lib\site-packages\webdriver_manager\drivers\chrome.py", line 64, in get_latest_release_version
    determined_browser_version = ".".join(determined_browser_version.split(".")[:3])
AttributeError: 'NoneType' object has no attribute 'split'

solution:
I changed shell=True to shell=False in webdriver_manager\core\utils.py, L43.
image

I recommend checking the system type to determine the value of this Boolean.

@zerxdapro
Copy link

Yeah, ive been having issues as well. Just confused, first time wanting to use google chrome through my bot. Just getting errors where its not finding google chrome. Am I supposed to install google chrome in my bots file? As this is in a server, not my own os.

@anonhostpi
Copy link

I think that is currently the expectation. Webdriver itself doesn't require a local installation of Chrome, but running Chrome remotely used to be a niche use case. This library was written when running remote instances wasn't very common. At least not as common as running it locally.

Technically, you only need chrome installed. I don't believe that this library actually launches Chrome.

@debthomaz
Copy link

I'm also getting this error and I don't know why, because I have Chrome installed.

@debthomaz
Copy link

debthomaz commented Jun 10, 2024

Hello guys!
Worked for me to download the chromedriver with the same version as my browser, using the link from this website: https://googlechromelabs.github.io/chrome-for-testing/#stable

And then I just provided the path like this:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

service = Service(executable_path='CHROME_DRIVER_PATH')
browser = webdriver.Chrome(service=service)

@KuleRucket
Copy link

KuleRucket commented Jul 2, 2024

This Solution written above works great for me running python under cygwin/Mobaterm. I think maybe the library is getting mixed up about whether I'm using Windows or Linux.

    from webdriver_manager.chrome import ChromeDriverManager
    print(ChromeDriverManager(driver_version='120').install())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests