You fire up your Selenium-based Chrome browser automation operation(s) one fine day and you are greeted with a godawful bit of an exception, at the bottom of which you read the following:
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
Puzzled, “It was working optimally just yesterday!”, you think to yourself, wondering what the variable causing this could be. The infamously trusty Stack Overflow does not tell you much about this, except that you probably need to explicitly set the Google Chrome binary’s path as so:
...
chromeOptions = webdriver.ChromeOptions()
chromeOptions.binary_location = "C:Program
FilesGoogleChromeApplication" chromeDriver = "/chromedriver.exe"
driver = webdriver.Chrome(chromeDriver, options=chromeOptions)
...
But, “dude”—you ask yourself—”why should I explicitly set the Google Chrome binary’s path?” or maybe “Why was this not required just yesterday?”
Well, for the curious minds that made it here, may you have the strength of a thousand Suns, for we are a different people that consist of special gears in our heads that start “churning” once an inconsistency makes its way into our lives; and instead of just “fixing” the capsizing ship with a chunky roll of Flex tape (not sponsored) over the cracks and holes, we would like to know how it happened, what made it happen, and why it happened—as we abandon ship and auto-inflate our enormous life raft (using Selenium, of course, ’cause “automation”) and then sail off into the sunset as we code an Apache helicopter into existence (what ship? Pfft).
“Now if there’s one thing you can be sure of, it’s that nothing is more powerful than a young boy’s wish. Except an Apache helicopter. An Apache helicopter has machine guns AND missiles. It is an unbelievably impressive complement of weaponry, an absolute death machine.” —Morgan-Freeman-sounding-but-not-Morgan-Freeman narrator — Ted (2012)
We have digressed far into the 3.5th dimension here; apologies, here’s the reason and possible fix!
Reason
NOTE: Just for the sake of clarity, this “Chrome binary” that Selenium is referring to is simply the OG big daddy main “Chrome.exe” file located in Google Chrome’s installation directory.
In previous versions of Google Chrome (v84 and below), Google Chrome’s default installation path—where “Chrome.exe” typically is—used to be:
C:UsersUSERNAMEAppDataLocalGoogle
But since the newer iteration(s) (v85 and above), the default installation path is:
C:Program FilesGoogle
Now, this is the problem. Where the older chromedriver.exe versions (v84 and below) intuitively expect the Chrome binary to be is in the former path, not the latter. If your Google Chrome browser naturally auto-updated from v84 to v85, this path remains unchanged (so chromedriver.exe has no issues navigating to it). However, if you explicitly installed or reinstalled Google Chrome on the latest version (v85 and above) recently, then the installation path changes to the newer one, and so, your older chromedriver.exe is not able to navigate to the Chrome binary; and this makes your code end with that particular “cannot find Chrome binary” exception. Ergo, this is why you are having to explicitly set the “binary_location” to the latter manually
NOTE: Since Google Chrome does not allow customizing the installation path while installing and just directly installs into Program Files by default, We have already tried a workaround and changed the default installation path itself from the registry (regedit); but to no avail, Google Chrome would then completely refuse to work once installed in the desired directory. It seems newer Google Chrome installations can only function if they are installed in the newer installation path.
Possible Fixes
Download the latest chromedriver.exe version that corresponds to your Google Chrome version (from here), and replace your existing chromedriver.exe with this new one.
Your problem should now be solved, since the newer chromedriver.exe is equipped with the knowledge that the new Google Chrome installation path is where it is supposed to look in order to find the Chrome binary.
But—for whatever reason—if you do not want to upgrade the chromedriver.exe version, you could just downgrade your Google Chrome version by obtaining an older version that corresponds to your chromedriver.exe version, uninstalling the newer version, and then installing the older version you had obtained.
NOTE: You will not find any official downloads for older Google Chrome versions since Google does not allow this for security reasons, but you may find some unofficial sources like this (personally tested and verified, safe). Also be informed that upon installing an older version of Google Chrome, auto-updates will no longer work anymore; so the only way for a potential future update would be via an uninstall and manual install of the latest Google Chrome version.
Содержание
- unknown error: cannot find Chrome binary #177
- Comments
- Footer
- WebDriverError: unknown error: cannot find Chrome binary #3614
- Comments
- Fix: Selenium’s “cannot find Chrome binary” Error
- Reason
- Possible Fixes
unknown error: cannot find Chrome binary #177
Cannot find Chrome binary when executing a selenium (testng) test in jenkins on Ubuntu
org.openqa.selenium.WebDriverException:
unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 4.10.0-37-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 9 milliseconds
Build info: version: ‘3.4.0’, revision: ‘unknown’, time: ‘unknown’
System info: host: ‘automation-tests-desktop’, ip: ‘127.0.1.1’, os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘4.10.0-37-generic’, java.version: ‘1.8.0_151’
Driver info: driver.version: ChromeDriver
The text was updated successfully, but these errors were encountered:
Install Chrome on Jenkins. Typically, you will need Xvfb (X virtual framebuffer) too.
File «/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py», line 312, in execute
self.error_handler.check_response(response)
File «/usr/local/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py», line 237, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.30,platform=Linux 3.10.0-693.17.1.el7.x86_64 x86_64)
org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.35.528139 (47ead77cb35ad2a9a83248b292151462a66cd881),platform=Linux 4.4.35-33.55.amzn1.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 19 milliseconds
Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:01:39.354Z’
System info: host: ‘Unknown’, ip: ‘Unknown’, os.name: ‘Linux’, os.arch: ‘amd64’, os.version: ‘4.4.35-33.55.amzn1.x86_64’, java.version: ‘1.8.0_151’
Driver info: driver.version: ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:142)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)
at Driver.driver.init(driver.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:59)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:451)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:222)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:163)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:105)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
at org.testng.TestNG.runSuites(TestNG.java:1028)
at org.testng.TestNG.run(TestNG.java:996)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:295)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:90)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
@ChandraShekarReddy1996 i have the same problem, did you solve it?
Any solution yet? I have similar problem
selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary
For java, I found that answer very helpful:
© 2023 GitHub, Inc.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Источник
WebDriverError: unknown error: cannot find Chrome binary #3614
I use protractor with a standalone Selenium Server and chrome browser
It work fine when I use Windows windows 7 but for Linux Binary chrome cannot be found.
I specified the binary’s path in attribute ‘chromeDriver’ for :
- ‘./node_modules/webdriver-manager/selenium/chromedriver_2.22.exe’ (for Windows 7)** 👍
- ‘./node_modules/webdriver-manager/selenium/chromedriver_2.22) (for Linux) 👎
I create 2 task in my gulptask file, one for update webdriver, and the other one to launch my tests.
These tasks are launched synchronously when webdriver-update is finish I launch my tests.
When I launch my tasks on Linux WebDriver cannot find Chrome binary
Download and unzip a this location by the task webdriver-update:
./node_modules/webdriver-manager/selenium/chromedriver_2.22linux64.zip
Protractor configuration file.
chromeDriver: ‘./node_modules/webdriver-manager/selenium/chromedriver_2.22’
[15:50:08] Using gulpfile /builds/lcab/lcab/Gulpfile.js
[15:50:08] Starting ‘protractor’.
[15:50:08] Starting ‘webdriver-update’.
webdriver-manager: using local installed version 10.2.3
[15:50:08] I/update — selenium standalone: file exists /builds/lcab/lcab/node_modules/webdriver-manager/selenium/selenium-server-standalone-2.53.1.jar
[15:50:08] I/update — selenium standalone: v2.53.1 up to date
[15:50:08] I/update — chromedriver: file exists /builds/lcab/lcab/node_modules/webdriver-manager/selenium/chromedriver_2.22linux64.zip
[15:50:08] I/update — chromedriver: unzipping chromedriver_2.22linux64.zip
[15:50:09] I/update — chromedriver: setting permissions to 0755 for /builds/lcab/lcab/node_modules/webdriver-manager/selenium/chromedriver_2.22
[15:50:09] I/update — chromedriver: v2.22 up to date
[15:50:09] Finished ‘webdriver-update’ after 698 ms
[15:50:09] Starting ‘e2e-tests’.
[15:50:09] D/launcher — Running with —troubleshoot
[15:50:09] D/launcher — Protractor version: 4.0.9
[15:50:09] D/launcher — Your base url for tests is http://.
[15:50:09] I/direct — Using ChromeDriver directly.
[15:50:09] I/launcher — Running 1 instances of WebDriver
[15:50:09] E/launcher — unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.22.397932 (282ed7cf89cf0053b6542e0d0f039d4123bbb6ad),platform=Linux 4.7.0-coreos x86_64)
[15:50:09] E/launcher — WebDriverError: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.22.397932 (282ed7cf89cf0053b6542e0d0f039d4123bbb6ad),platform=Linux 4.7.0-coreos x86_64)
at WebDriverError (/builds/lcab/lcab/node_modules/selenium-webdriver/lib/error.js:27:5)
at Object.checkLegacyResponse (/builds/lcab/lcab/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/builds/lcab/lcab/node_modules/selenium-webdriver/http/index.js:538:13)
at client_.send.then.response (/builds/lcab/lcab/node_modules/selenium-webdriver/http/index.js:472:11)
at ManagedPromise.invokeCallback_ (/builds/lcab/lcab/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/builds/lcab/lcab/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/builds/lcab/lcab/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at asyncRun (/builds/lcab/lcab/node_modules/selenium-webdriver/lib/promise.js:2820:25)
at /builds/lcab/lcab/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.createSession (/builds/lcab/lcab/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Driver (/builds/lcab/lcab/node_modules/selenium-webdriver/chrome.js:778:38)
at Direct.getNewDriver (/builds/lcab/lcab/node_modules/protractor/built/driverProviders/direct.js:68:26)
at Runner.createBrowser (/builds/lcab/lcab/node_modules/protractor/built/runner.js:198:43)
at /builds/lcab/lcab/node_modules/protractor/built/runner.js:277:30
at _fulfilled (/builds/lcab/lcab/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/builds/lcab/lcab/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/builds/lcab/lcab/node_modules/q/q.js:796:13)
at /builds/lcab/lcab/node_modules/q/q.js:556:49
at runSingle (/builds/lcab/lcab/node_modules/q/q.js:137:13)
[15:50:09] E/launcher — Process exited with error code 199
/builds/lcab/lcab/app/Resources/gulpFiles/unitsTestingFront.js:52
throw e;
^
Error: protractor exited with code 199
ERROR: Build failed: exit code 1`
my protractor conf file
I’v tried to install chromedriver in nodes modules and add the chrome binary path to chromedriver attribute but it work only on window and I also try to add this conf to protractor but it seem to be deprecated :
The text was updated successfully, but these errors were encountered:
Источник
Fix: Selenium’s “cannot find Chrome binary” Error
Skip to entry content
You fire up your Selenium-based Chrome browser automation operation(s) one fine day and you are greeted with a godawful bit of an exception, at the bottom of which you read the following:
Puzzled, “It was working optimally just yesterday!”, you think to yourself, wondering what the variable causing this could be. The infamously trusty Stack Overflow does not tell you much about this, except that you probably need to explicitly set the Google Chrome binary’s path as so:
But, “dude”—you ask yourself—”why should I explicitly set the Google Chrome binary’s path?” or maybe “Why was this not required just yesterday?”
Well, for the curious minds that made it here, may you have the strength of a thousand Suns, for we are a different people that consist of special gears in our heads that start “churning” once an inconsistency makes its way into our lives; and instead of just “fixing” the capsizing ship with a chunky roll of Flex tape (not sponsored) over the cracks and holes, we would like to know how it happened, what made it happen, and why it happened—as we abandon ship and auto-inflate our enormous life raft (using Selenium, of course, ’cause “automation”) and then sail off into the sunset as we code an Apache helicopter into existence (what ship? Pfft).
“ Now if there’s one thing you can be sure of, it’s that nothing is more powerful than a young boy’s wish. Except an Apache helicopter. An Apache helicopter has machine guns AND missiles. It is an unbelievably impressive complement of weaponry, an absolute death machine. ” —Morgan-Freeman-sounding-but-not-Morgan-Freeman narrator — Ted (2012)
We have digressed far into the 3.5 th dimension here; apologies, here’s the reason and possible fix!
Reason
NOTE: Just for the sake of clarity, this “Chrome binary” that Selenium is referring to is simply the OG big daddy main “Chrome.exe” file located in Google Chrome’s installation directory.
In previous versions of Google Chrome (v84 and below), Google Chrome’s default installation path—where “Chrome.exe” typically is—used to be:
But since the newer iteration(s) (v85 and above), the default installation path is:
Now, this is the problem. Where the older chromedriver.exe versions (v84 and below) intuitively expect the Chrome binary to be is in the former path, not the latter. If your Google Chrome browser naturally auto-updated from v84 to v85, this path remains unchanged (so chromedriver.exe has no issues navigating to it). However, if you explicitly installed or reinstalled Google Chrome on the latest version (v85 and above) recently, then the installation path changes to the newer one, and so, your older chromedriver.exe is not able to navigate to the Chrome binary; and this makes your code end with that particular “cannot find Chrome binary” exception. Ergo, this is why you are having to explicitly set the “binary_location” to the latter manually
NOTE: Since Google Chrome does not allow customizing the installation path while installing and just directly installs into Program Files by default, We have already tried a workaround and changed the default installation path itself from the registry (regedit); but to no avail, Google Chrome would then completely refuse to work once installed in the desired directory. It seems newer Google Chrome installations can only function if they are installed in the newer installation path.
Possible Fixes
Download the latest chromedriver.exe version that corresponds to your Google Chrome version (from here ), and replace your existing chromedriver.exe with this new one.
Your problem should now be solved, since the newer chromedriver.exe is equipped with the knowledge that the new Google Chrome installation path is where it is supposed to look in order to find the Chrome binary.
But—for whatever reason—if you do not want to upgrade the chromedriver.exe version, you could just downgrade your Google Chrome version by obtaining an older version that corresponds to your chromedriver.exe version, uninstalling the newer version, and then installing the older version you had obtained.
NOTE: You will not find any official downloads for older Google Chrome versions since Google does not allow this for security reasons, but you may find some unofficial sources like this (personally tested and verified, safe). Also be informed that upon installing an older version of Google Chrome, auto-updates will no longer work anymore; so the only way for a potential future update would be via an uninstall and manual install of the latest Google Chrome version.
Источник
With the message: unknown error: cannot find Chrome binary” on Mac
I was using Selenium with Python 3 for web scraping purposes:
from selenium import webdriver chrome_path = r"/Library/Frameworks/Python.framework/Versions/3.6/bin/chromedriver" driver = webdriver.Chrome(chrome_path)
I got an error
selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary
May 8, 2018
in Selenium
by
• 4,320 points
•
15,020 views
1 answer to this question.
In your case the path of the chrome is at a non-default path. So, you need to specify the complete path to the Google Chrome binary.
options = webdriver.ChromeOptions()
options.binary_location = «/Applications/Google Chrome.app/Contents/MacOS/Google Chrome»
chrome_driver_binary = «/usr/local/bin/chromedriver»
driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)
Above code is what you should use
answered
May 8, 2018
by
Samarpit
• 5,890 points
Related Questions In Selenium
- All categories
-
ChatGPT
(4) -
Apache Kafka
(84) -
Apache Spark
(596) -
Azure
(131) -
Big Data Hadoop
(1,907) -
Blockchain
(1,673) -
C#
(141) -
C++
(271) -
Career Counselling
(1,060) -
Cloud Computing
(3,446) -
Cyber Security & Ethical Hacking
(147) -
Data Analytics
(1,266) -
Database
(855) -
Data Science
(75) -
DevOps & Agile
(3,575) -
Digital Marketing
(111) -
Events & Trending Topics
(28) -
IoT (Internet of Things)
(387) -
Java
(1,247) -
Kotlin
(8) -
Linux Administration
(389) -
Machine Learning
(337) -
MicroStrategy
(6) -
PMP
(423) -
Power BI
(516) -
Python
(3,188) -
RPA
(650) -
SalesForce
(92) -
Selenium
(1,569) -
Software Testing
(56) -
Tableau
(608) -
Talend
(73) -
TypeSript
(124) -
Web Development
(3,002) -
Ask us Anything!
(66) -
Others
(1,938) -
Mobile Development
(263)
Subscribe to our Newsletter, and get personalized recommendations.
Already have an account? Sign in.