Skip to content
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

selenium.common.exceptions.WebDriverException: Message: unknown error: c annot find Chrome binary #206

Closed
ithjz opened this issue Sep 19, 2018 · 11 comments
Labels
question Someone is looking for answers

Comments

@ithjz
Copy link

ithjz commented Sep 19, 2018

        exception_class = ElementNotVisibleException
    elif status in ErrorCode.INVALID_ELEMENT_STATE:
        exception_class = InvalidElementStateException
    elif status in ErrorCode.INVALID_SELECTOR \
            or status in ErrorCode.INVALID_XPATH_SELECTOR \
            or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
        exception_class = InvalidSelectorException
    elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
        exception_class = ElementNotSelectableException
    elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
        exception_class = ElementNotInteractableException
    elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
        exception_class = InvalidCookieDomainException
    elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
        exception_class = UnableToSetCookieException
    elif status in ErrorCode.TIMEOUT:
        exception_class = TimeoutException
    elif status in ErrorCode.SCRIPT_TIMEOUT:
        exception_class = TimeoutException
    elif status in ErrorCode.UNKNOWN_ERROR:
        exception_class = WebDriverException
    elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
        exception_class = UnexpectedAlertPresentException
    elif status in ErrorCode.NO_ALERT_OPEN:
        exception_class = NoAlertPresentException
    elif status in ErrorCode.IME_NOT_AVAILABLE:
        exception_class = ImeNotAvailableException
    elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
        exception_class = ImeActivationFailedException
    elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
        exception_class = MoveTargetOutOfBoundsException
    elif status in ErrorCode.JAVASCRIPT_ERROR:
        exception_class = JavascriptException
    elif status in ErrorCode.SESSION_NOT_CREATED:
        exception_class = SessionNotCreatedException
    elif status in ErrorCode.INVALID_ARGUMENT:
        exception_class = InvalidArgumentException
    elif status in ErrorCode.NO_SUCH_COOKIE:
        exception_class = NoSuchCookieException
    elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
        exception_class = ScreenshotException
    elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
        exception_class = ElementClickInterceptedException
    elif status in ErrorCode.INSECURE_CERTIFICATE:
        exception_class = InsecureCertificateException
    elif status in ErrorCode.INVALID_COORDINATES:
        exception_class = InvalidCoordinatesException
    elif status in ErrorCode.INVALID_SESSION_ID:
        exception_class = InvalidSessionIdException
    elif status in ErrorCode.UNKNOWN_METHOD:
        exception_class = UnknownMethodException
    else:
        exception_class = WebDriverException
    if value == '' or value is None:
        value = response['value']
    if isinstance(value, basestring):
        if exception_class == ErrorInResponseException:
            raise exception_class(response, value)
        raise exception_class(value)
    if message == "" and 'message' in value:
        message = value['message']

    screen = None
    if 'screen' in value:
        screen = value['screen']

    stacktrace = None
    if 'stackTrace' in value and value['stackTrace']:
        stacktrace = []
        try:
            for frame in value['stackTrace']:
                line = self._value_or_default(frame, 'lineNumber', '')
                file = self._value_or_default(frame, 'fileName', '<anonymous

')
if line:
file = "%s:%s" % (file, line)
meth = self._value_or_default(frame, 'methodName', '')
if 'className' in frame:
meth = "%s.%s" % (frame['className'], meth)
msg = " at %s (%s)"
msg = msg % (meth, file)
stacktrace.append(msg)
except TypeError:
pass
if exception_class == ErrorInResponseException:
raise exception_class(response, message)
elif exception_class == UnexpectedAlertPresentException:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.WebDriverException: Message: unknown error: c
annot find Chrome binary
E (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3e
b905c4f5ab),platform=Windows NT 6.1.7601 SP1 x86_64)

e:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandle
r.py:242: WebDriverException

During handling of the above exception, another exception occurred:
..\seleniumbase\fixtures\base_case.py:3085: in setUp
switch_to=True)
..\seleniumbase\fixtures\base_case.py:2496: in get_new_driver
proxy_string=proxy_string)
..\seleniumbase\core\browser_launcher.py:161: in get_driver
return get_local_driver(browser_name, headless, proxy_string)
..\seleniumbase\core\browser_launcher.py:342: in get_local_driver
return webdriver.Chrome(executable_path=LOCAL_CHROMEDRIVER)
e:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.p
y:75: in init
desired_capabilities=desired_capabilities)
e:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.p
y:156: in init
self.start_session(capabilities, browser_profile)
e:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.p
y:251: in start_session
response = self.execute(Command.NEW_SESSION, parameters)
e:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.p
y:320: in execute
self.error_handler.check_response(response)


self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x00000000
04F34EF0>
response = {'sessionId': '7f07e0ad8bb1dbd36eb27c3283d5a58d', 'status': 13, 'valu
e': {'message': 'unknown error: cannot find Chrom...r info: chromedriver=2.40.56
5498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 6.1.7601 SP1
x86_64)'}}

def check_response(self, response):
    """
        Checks that a JSON response from the WebDriver does not have an erro

r.

        :Args:
         - response - The JSON response from the WebDriver server as a dicti

onary
object.

        :Raises: If the response contains an error message.
        """
    status = response.get('status', None)
    if status is None or status == ErrorCode.SUCCESS:
        return
    value = None
    message = response.get("message", "")
    screen = response.get("screen", "")
    stacktrace = None
    if isinstance(status, int):
        value_json = response.get('value', None)
        if value_json and isinstance(value_json, basestring):
            import json
            try:
                value = json.loads(value_json)
                if len(value.keys()) == 1:
                    value = value['value']
                status = value.get('error', None)
                if status is None:
                    status = value["status"]
                    message = value["value"]
                    if not isinstance(message, basestring):
                        value = message
                        message = message.get('message')
                else:
                    message = value.get('message', None)
            except ValueError:
                pass

    exception_class = ErrorInResponseException
    if status in ErrorCode.NO_SUCH_ELEMENT:
        exception_class = NoSuchElementException
    elif status in ErrorCode.NO_SUCH_FRAME:
        exception_class = NoSuchFrameException
    elif status in ErrorCode.NO_SUCH_WINDOW:
        exception_class = NoSuchWindowException
    elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
        exception_class = StaleElementReferenceException
    elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
        exception_class = ElementNotVisibleException
    elif status in ErrorCode.INVALID_ELEMENT_STATE:
        exception_class = InvalidElementStateException
    elif status in ErrorCode.INVALID_SELECTOR \
            or status in ErrorCode.INVALID_XPATH_SELECTOR \
            or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
        exception_class = InvalidSelectorException
    elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
        exception_class = ElementNotSelectableException
    elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
        exception_class = ElementNotInteractableException
    elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
        exception_class = InvalidCookieDomainException
    elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
        exception_class = UnableToSetCookieException
    elif status in ErrorCode.TIMEOUT:
        exception_class = TimeoutException
    elif status in ErrorCode.SCRIPT_TIMEOUT:
        exception_class = TimeoutException
    elif status in ErrorCode.UNKNOWN_ERROR:
        exception_class = WebDriverException
    elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
        exception_class = UnexpectedAlertPresentException
    elif status in ErrorCode.NO_ALERT_OPEN:
        exception_class = NoAlertPresentException
    elif status in ErrorCode.IME_NOT_AVAILABLE:
        exception_class = ImeNotAvailableException
    elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
        exception_class = ImeActivationFailedException
    elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
        exception_class = MoveTargetOutOfBoundsException
    elif status in ErrorCode.JAVASCRIPT_ERROR:
        exception_class = JavascriptException
    elif status in ErrorCode.SESSION_NOT_CREATED:
        exception_class = SessionNotCreatedException
    elif status in ErrorCode.INVALID_ARGUMENT:
        exception_class = InvalidArgumentException
    elif status in ErrorCode.NO_SUCH_COOKIE:
        exception_class = NoSuchCookieException
    elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
        exception_class = ScreenshotException
    elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
        exception_class = ElementClickInterceptedException
    elif status in ErrorCode.INSECURE_CERTIFICATE:
        exception_class = InsecureCertificateException
    elif status in ErrorCode.INVALID_COORDINATES:
        exception_class = InvalidCoordinatesException
    elif status in ErrorCode.INVALID_SESSION_ID:
        exception_class = InvalidSessionIdException
    elif status in ErrorCode.UNKNOWN_METHOD:
        exception_class = UnknownMethodException
    else:
        exception_class = WebDriverException
    if value == '' or value is None:
        value = response['value']
    if isinstance(value, basestring):
        if exception_class == ErrorInResponseException:
            raise exception_class(response, value)
        raise exception_class(value)
    if message == "" and 'message' in value:
        message = value['message']

    screen = None
    if 'screen' in value:
        screen = value['screen']

    stacktrace = None
    if 'stackTrace' in value and value['stackTrace']:
        stacktrace = []
        try:
            for frame in value['stackTrace']:
                line = self._value_or_default(frame, 'lineNumber', '')
                file = self._value_or_default(frame, 'fileName', '<anonymous

')
if line:
file = "%s:%s" % (file, line)
meth = self._value_or_default(frame, 'methodName', '')
if 'className' in frame:
meth = "%s.%s" % (frame['className'], meth)
msg = " at %s (%s)"
msg = msg % (meth, file)
stacktrace.append(msg)
except TypeError:
pass
if exception_class == ErrorInResponseException:
raise exception_class(response, message)
elif exception_class == UnexpectedAlertPresentException:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.WebDriverException: Message: unknown error: c
annot find Chrome binary
E (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3e
b905c4f5ab),platform=Windows NT 6.1.7601 SP1 x86_64)

e:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandle
r.py:242: WebDriverException
============================== warnings summary ===============================
source:1067: DeprecationWarning: invalid escape sequence \S
source:1168: DeprecationWarning: invalid escape sequence \S
source:1289: DeprecationWarning: invalid escape sequence \S
source:131: DeprecationWarning: invalid escape sequence \d
source:141: DeprecationWarning: invalid escape sequence \d
source:358: DeprecationWarning: invalid escape sequence _
source:374: DeprecationWarning: invalid escape sequence _
source:625: DeprecationWarning: invalid escape sequence *
source:649: DeprecationWarning: invalid escape sequence *

-- Docs: https://docs.pytest.org/en/latest/warnings.html
==================== 1 failed, 9 warnings in 8.33 seconds =====================

E:\users\administrator\eclipse-workspace2\SeleniumBase-master\examples>

@mdmintz
Copy link
Member

mdmintz commented Sep 19, 2018

Hi @ithjz Have you tried using seleniumbase install chromedriver ? It doesn't seem to be on your path.

@mdmintz
Copy link
Member

mdmintz commented Sep 19, 2018

Additionally, get the new seleniumbase version 1.15.8 to take care of those deprecation warnings you see, which are related to the version of python used. Also, add a "--upgrade" to your pip install to make sure you have the latest versions of python packages being used: pip install -r requirements.txt --upgrade

@mdmintz
Copy link
Member

mdmintz commented Sep 20, 2018

@ithjz Now, v1.15.10 should take care of the remaining DeprecationWarnings you saw (https://github.com/seleniumbase/SeleniumBase/pull/209/files), which updated methods that use regular expressions to pass raw strings. Use pip install -U seleniumbase --no-cache-dir to reinstall from pypi, (Or pip install -U -i https://pypi.anaconda.org/seleniumbase/simple seleniumbase if you're using Anaconda Cloud). Then get chromedriver into your seleniumbase drivers folder with seleniumbase install chromedriver.

@mdmintz
Copy link
Member

mdmintz commented Sep 23, 2018

I haven't heard back in 4 days, so I'll assume this issue is resolved. Please update to the latest version of seleniumbase if you haven't already.

@mdmintz mdmintz closed this as completed Sep 23, 2018
@bschollnick
Copy link

(In case someone else runs into this.)
I was seeing the same issue under Windows Server.

seleniumbase install chromedriver

Worked fine, no errors, but seleniumbase would die with "cannot find Chrome Binary".

For some reason, I HAD to use seleniumbase install chromedriver latest.

As soon as I did that, everything worked fine.

@bukowa
Copy link

bukowa commented Mar 22, 2021

  ** install **

  Usage:
          seleniumbase install [DRIVER_NAME] [OPTIONS]
              (Drivers: chromedriver, geckodriver, edgedriver,
                        iedriver, operadriver)
  Options:
          VERSION         Specify the version.
                          (Default chromedriver version = 2.44)
                          Use "latest" for the latest version.
          -p OR --path    Also copy the driver to /usr/local/bin

It would be cool to specify custom path!

@mdmintz
Copy link
Member

mdmintz commented Mar 22, 2021

@bukowa It can always be copied to another location, but these are the safe paths to use. There could be permissions issues, etc, when using other paths. The only time that the seleniumbase/drivers folder isn't good enough is when using a Selenium Grid - that requires the driver to be on the system path. Otherwise, it's safer to use seleniumbase/drivers because then you could have a different version of the browser driver for different virtual environments. If the system path is used, all users would have to use the same driver.

@bukowa
Copy link

bukowa commented Nov 11, 2022

(venv) (⎈|N/A:default)➜  tests git:(new2) ✗ seleniumbase install chromedriver latest

*** chromedriver version for download = 107.0.5304.62 (Latest)

Downloading chromedriver_linux64.zip from:
https://chromedriver.storage.googleapis.com/107.0.5304.62/chromedriver_linux64.zip ...
Download Complete!

Extracting ['chromedriver'] from chromedriver_linux64.zip ...
Unzip Complete!

The file [chromedriver] was saved to:
/home/buk/Git/k8s-wp/venv/lib/python3.10/site-packages/seleniumbase/drivers/chromedriver

Making [chromedriver 107.0.5304.62] executable ...
[chromedriver 107.0.5304.62] is now ready for use!
(venv) (⎈|N/A:default)➜  tests git:(new2) ✗ pytest .                                
(Linux uses --headless by default. To override, use --headed / --gui. For Xvfb mode instead, use --xvfb. Or hide this info with --headless, or by calling the new --headless2.)
==================================================================================================================== test session starts =====================================================================================================================
platform linux -- Python 3.10.6, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/buk/Git/k8s-wp/tests
plugins: html-2.0.1, metadata-2.0.4, xdist-3.0.2, forked-1.4.0, rerunfailures-10.2, seleniumbase-4.8.2, ordering-0.6
collected 1 item                                                                                                                                                                                                                                             

basic_test.py

FAILED basic_test.py::MyTestClass::test_basics - selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

I wonder why it still doesn't work out of the box with venv :/

@bukowa
Copy link

bukowa commented Nov 11, 2022

It works with firefox seleniumbase install geckodriver pytest --headed --browser=firefox

@mdmintz
Copy link
Member

mdmintz commented Nov 11, 2022

@bukowa cannot find Chrome binary means that Chrome wasn't found on your machine. Chrome must be installed separately. (SeleniumBase only downloads the drivers for you.)

@bukowa
Copy link

bukowa commented Nov 11, 2022

@bukowa cannot find Chrome binary means that Chrome wasn't found on your machine. Chrome must be installed separately. (SeleniumBase only downloads the drivers for you.)

Oh ok thank you

@mdmintz mdmintz added the question Someone is looking for answers label Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Someone is looking for answers
Projects
None yet
Development

No branches or pull requests

4 participants