For compatibility reasons I prefer to use Chrome version 55.0.2883.75 with Chromedriver v. 2.26. I downloaded the older version of chrome from https://www.slimjet.com/chrome/google-chrome-old-version.php and Chromedriver 2.26 from https://chromedriver.storage.googleapis.com/index.html?path=2.26/.
I am using the following code to attempt to set my Chrome binary location:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome('chromedriver.exe', chrome_options = options)
However, when I attempt to launch the WebDriver Python returns the following error:
WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362
(5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 10.0.14393 x86_64)
I have tried searching through similar questions and answers but have not had any luck so far. Any help is greatly appreciated - thank you in advance!
This error message...
WebDriverException: unknown error: cannot find Chrome binary
...implies that the ChromeDriver was unable to find the Chrome binary in the default location for your system.
As per the ChromeDriver - Requirements:
The server expects you to have Chrome installed in the default location for each system:
OS
Expected Location of Chrome
Linux
/usr/bin/google-chrome1
Mac
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
Windows XP
%HOMEPATH%\Local Settings\Application Data\Google\Chrome\Application\chrome.exe
Windows Vista and newer
C:\Users%USERNAME%\AppData\Local\Google\Chrome\Application\chrome.exe
1 For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary.
Using a Chrome executable in a non-standard location
However you can also override the default Chrome binary location as follows:
To use Chrome version 55.x installed in non standard location through ChromeDriver v2.26 you can use the following code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\\Program Files\\Chrome\\chrome64_55.0.2883.75\\chrome.exe"
driver = webdriver.Chrome(chrome_options = options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
print("Chrome Browser Invoked")
driver.quit()
Related Docs
Reference
You can find a detailed discussion in:
Is Chrome installation needed or only chromedriver when using Selenium?
What happened to me is that I didn't have chrome, the main browser, installed.
Download the browser and it fixes this issue.
Using an old version of chrome driver with the latest Google Chrome locally gave me the same exception.
Just go to the ChromeDriver page and make sure you have the latest version.
I faced similar issue in MacOS. Even after setting binary path in chromeoptions, it didn't work. It got fixed after installing npm i chromedriver
It is also important to download Chrome from the actual website. I ran into the same problem, but I had downloaded Chrome from the Ubuntu software package manager. I uninstalled the package manager version and installed from the website, and the error resolved. Same issue could probably arise installing from other package managers.
Check https://sites.google.com/a/chromium.org/chromedriver/getting-started
You can specify the binary path in the constructor of the webdriver:
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
I did this to solve my problem
private WebDriver driver;
#Before
public void StartBrowser() {
System.setProperty("webdriver.chrome.driver", "C://opt//WebDriver//bin//chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.saucedemo.com/");}
I have solved this problem by installing Google Chrome link and it solved problem automatically (I use Kali Linux) and be sure that it is installed to the "/usr/bin"(default it is downloaded to here).
Related
I am looking to install Chrome Driver (For my selenium project) on an Amazon Linux 2 (Arm 64).
I have done this on Ubuntu and seems pretty straight, it also seems straight on AL2 x86, like this script from Intoli but it 404 when looking for Chrome on ARM :(. So far I see Chrome is not available for ARM so I see the alternative is to use Chromium.
I tried installing it manually but it seems there is no compiled on Chromium downloads page for ARM.
Finally i found the Electron's unofficial webdrivers, which seem to be the answer, and after downloading, installing dependencies (libXcursor, libXfixes, libXdamage) and running it:
[ec2-user#scraping1 current]$ chromedriver
Starting ChromeDriver 100.0.4896.143 (6bf1afe83487405ea0aff37182f05e3db45559c2-refs/branch-heads/4951#{#831}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
And run my project I get:
2.7.3 :004 > Selenium::WebDriver::Service.driver_path = "/usr/bin/chromedriver"
=> "/usr/bin/chromedriver"
session = Capybara::Session.new
Webdrivers::BrowserNotFound: Failed to find Chrome binary.
Which means i don't have Chrome installed, but then how to install it? I have seen this question which seems to be my same problem but it is unclear to me how to install Chromium; I see it is needed to download and use the chromedriver compiled for ARM64 which I have done already.
I'm trying to automate a process using selenium. When I run the code it gives me the error bellow.
WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.22000 x86_64)
I have downloaded the new driver and passed the variable in system variables under path. Can anyone please help me figure this out. I'm a student just starting my tech career.
This question has been asked many times before in similar disguises and the answers have usually advised to match versions. However, i have often struggled to match versions (for various reasons) and this is rather cumbersome when the versions keep changing.
For this reason, I use the ChromeDriverManager() which installs the correct version at each time.
You need to install webdriver-manager:
pip install webdriver-manager
And this is the working code
# selenium 4
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
service=Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=service)
You can find the docs here:
https://pypi.org/project/webdriver-manager/
This module recognises and has solved a problem for us all:
It’s boring!!! Moreover every time the new version of driver released, you should go and repeat all steps again and again.
I hope it helps.
This error message...
WebDriverException: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.39.562718
...implies that the ChromeDriver was unable to locate the google-chrome executable.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.39
As per this discussion chromedriver=2.39 :
Supports Chrome v66-68
Possibly you are using the latest chrome=99.0
Release Notes of ChromeDriver v99.0.4844.51 clearly mentions the following :
Supports Chrome version 99
So there is a clear mismatch between chromedriver=2.39 and the chrome=99.0
Solution
Ensure that:
Selenium is upgraded to current released Version 4.1.3.
ChromeDriver is updated to current ChromeDriver v99.0 level.
Chrome Browser is updated to current chrome=99.0 (as per chromedriver=99.0.4844.51 release notes).
I am executing selenium test via Jenkins server in AWS Ubuntu.
I was getting chrome binary not found error so I set chrome binary in my code.
System.setProperty("webdriver.chrome.driver","/var/lib/jenkins/.m2/repository/webdriver/chromedriver/linux64/83.0.4103.39/chromedriver");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("applicationCacheEnabled", true);
ChromeOptions options = new ChromeOptions();
options.merge(capabilities);
options.setBinary("/usr/bin/google-chrome-stable");
options.addArguments("--headless");
options.addArguments("--no-sandbox");
options.addArguments("--remote-debugging-port=9222");
options.addArguments("--disable-infobars");
options.addArguments("--disable-dev-shm-usage"); //Linux
options.addArguments("--disable-browser-side-navigation");
options.addArguments("--disable-gpu"); //Windows
options.addArguments("--disable-web-security");
driver = new ChromeDriver(options);
Then the error changed to: no chrome binary at /usr/bin/google-chrome-stable
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103#{#416}) on port 14665
Only local connections are allowed.
ChromeDriver was started successfully.
INFO [main] (ControlCenter.java:108)- START
[ERROR] Tests run: 4, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 2.116 s <<< FAILURE! - in TestSuite
[ERROR] com.info.end2end.ExcelAccountToFusion.onTestSetup Time elapsed: 2.032 s <<< FAILURE!
org.openqa.selenium.WebDriverException:
**unknown error: no chrome binary at /usr/bin/google-chrome-stable**
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'jenkins-it02', ip: '10.113.0.187', os.name: 'Linux', os.arch: 'amd64', os.version: '5.3.0-1019-aws', java.version: '11.0.7'
Driver info: driver.version: ChromeDriver
This is how my usr/bin is:
And this is message when I try to launch browser in command line:
I tried the solution given by #DebanjanB at Cannot find Chrome binary with Selenium in Python for older versions of Google Chrome but no luck. Any help is much appreciated as I have spent 2 days on this already.
Not sure if setBinary() should be pointing to /usr/bin/google-chrome-stable.
As per the documentation in How To Install Google Chrome 78 On a RHEL/CentOS 7 and Fedora Linux to install and use the latest google-chrome using Yum you need to follow the sequence below:
Open the Terminal application. Grab 64bit Google Chrome installer.
Type the following command to download 64 bit version of Google Chrome:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
Install Google Chrome and its dependencies on a CentOS/RHEL, type:
sudo yum install ./google-chrome-stable_current_*.rpm
Start Google Chrome from the CLI:
google-chrome &
Outputs from yum command:
Finally, you need to use the following line to set the chrome binary:
options.setBinary("/usr/bin/google-chrome");
Additional Considerations
Ensure that:
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Reference
You can find a couple of relevant discussions in:
Cannot find Chrome binary with Selenium in Python for older versions of Google Chrome
I did not have the actual fix for this issue but I could get around my actual blocker by installing Chromium instead of Chrome. Difference I found is the installation directory of both.
I installed Chrome and whereis Google-Chrome-Stable gives:
qa_user#jenkins:~$ whereis google-chrome-stable google-chrome-stable: /usr/bin/google-chrome-stable /usr/share/man/man1/google-chrome-stable.1.gz
And qa_user#jenkins:~$ google-chrome-stable gives: google-chrome-stable: command not found
Now for Chromium:
qa_user#jenkins:~$ whereis chromium-browser gives: chromium-browser: /usr/bin/chromium-browser /usr/lib/chromium-browser /etc/chromium-browser /usr/share/chromium-browser /usr/share/man/man1/chromium-browser.1.gz
and qa_user#jenkins~$ chromium-browser [21304:21304:0607/135202.629230:ERROR:browser_main_loop.cc(1473)] Unable to open X display. Identifies and opens Chromium (X display issue can be solved by adding --headless option in actual Selenium code).
So I am gonna use Chromium instead of Chrome until I/Someone here find the fix for the actual Chrome issue here.
UPDATE:
After my below solution, I uninstalled Chromium and kept only Chrome for further testing. Surprisingly, chrome issue got fixed. I am able to run tests in Chrome now. Not sure how this is happening but I think it has something to do with dependency package that comes with Chrome.
I know this is strange but installing Chrome and Chromium and then uninstalling Chromium worked for me.
I have installed selenium and the chrome web driver and made it accessible via the path variable of my operating system (using Linux virtual machine on windows and python3). I run this simple code and get the below error. Any ideas as to what may cause this error?
Thanks in advance!
Selenium version installed:
selenium-3.141.0 urllib3-1.25.8
Chrome driver installed (latest version for chrome browser 80) :
ChromeDriver 80.0.3987.106 (f68069574609230cf9b635cd784cfb1bf81bb53a-refs/branch-heads/3987#{#882})
Chrome browser installed :
Google Chrome 80.0.3987.132
Python version :
Python 3.6.9
import selenium
from selenium import webdriver
options = webdriver.chrome.options.Options()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
chromedriver = '/usr/bin/chromedriver'
print('test0') #is being printed
driver = webdriver.Chrome('/usr/bin/chromedriver',options=options)
print('test') #not being printed
driver.get('http:google.com')
Error message when running the code : The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.
When I try to run google-chrome with (sudo google-chrome) I get this message:
[56:56:0316/235226.650275:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
I tried modifying the google-chrome file in the /usr/bin but it is read-only so the workaround I found online was to add the options '--no-sandbox' in my code above. But hasn't resolved the issue.
Resolved : had a python file named queue in working directory and had to rename it
Solution:
This error "AttributeError: 'LifoQueue' object has no attribute 'put' selenium webdriver" is caused by having in your working directory a file with the name Queue. Rename that.
For this error "The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed."
If you tried all possible solutions and still get issues then if you are using Linux virtual machine that seems to be causing the problem and I suggest to install docker desktop on windows and download a docker image with all the libraries you will be needing to run selenium apps .
I am trying to create a webcrawler using Selenium, but I get this error when I try to create the webdriver object.
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome version must be between 70 and 73
(Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 6.1.7601 SP1 x86_64)
I downloaded the latest version of chromedriver (2.45) which requires Chrome 70-73. My current Chrome version is 68.0.3440.106 (Official Build) (64-bit), which is the latest. I tried downloading an "older" chrome version (71) and when I tried installing it, the installer indicated that I had a newer version already installed.
There doesn't seem to be any previous Chromedriver releases available for download, even though the website says there is. I couldn't find them.
I don't quite understand how version 71 is older than 68?
Is there a Chrome version newer than 68 actually available, or an older version of chromedriver i can use with Chrome 68?
Does anyone have any other suggestions?
This is the code that i'm trying to execute:
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
user = 'XXXXXXX'
pwd = 'XXXXXXX'
chromedriver = "...\...\...\chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver) # Error occurs at this line
driver.get("http://www.facebook.com")
assert "Facebook" in driver.title
time.sleep(5) # So i can see something!
elem = driver.find_element_by_id("email")
elem.send_keys(user)
time.sleep(5) # So i can see something!
elem = driver.find_element_by_id("pass")
elem.send_keys(pwd)
time.sleep(5) # So i can see something!
elem.send_keys(Keys.RETURN)
driver.close()
For me, upgrading the driver did the trick. Just run:
brew cask upgrade chromedriver
and then try running your test again. Hope it helps!
You can find the older versions of chrome driver here.
I dont think it is a good idea to install chrome from sources other than the official channel and installation of the same can cause issues. See if the google update service is running in your PC. This will automatically update the chrome version to latest. Mine is running Version 71.0.3578.98 (Official Build) (64-bit).
This error message...
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome version must be between 70 and 73
(Driver info: chromedriver=2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 6.1.7601 SP1 x86_64)
...implies that Chrome version must be between 70 and 73
Your main issue is the version compatibility between the binaries you are using as follows :
You are using chromedriver=2.45
Release Notes of chromedriver=2.45 clearly mentions the following :
Supports Chrome v70-72
You are using chrome=68.0
Release Notes of ChromeDriver v2.41 clearly mentions the following :
Supports Chrome v67-69
So there is a clear mismatch between ChromeDriver v2.45 and the Chrome Browser v68.0
Solution
Upgrade ChromeDriver to current ChromeDriver v2.45 level.
Keep Chrome version between Chrome v70-72 levels. (as per ChromeDriver v2.45 release notes)
Take a System Reboot.
Execute your #Test.
Alternative
Somehow I feel there are 2 versions of Chrome browser installed in your system. If that is the case you need to mention the absolute location of the Chrome binary within your program and you can use the following solution:
Code Block:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
driver = webdriver.Chrome(chrome_options=options, executable_path="C:/Utility/BrowserDrivers/chromedriver.exe", )
driver.get('http://google.com/')
You can find a detailed discussion in Set chrome browser binary through chromedriver in Python
Note: You can find a relevant discussion in Session not created exception: Chrome version must be >= x.y.z when using Selenium Webdriver with Chrome
Reference
You can find a relevant detailed discussion in:
How to work with a specific version of ChromeDriver while Chrome Browser gets updated automatically through Python selenium
There are two options to resolve this issue:
1. If your Chrome version is not updated -> Update it
Steps: 1. Go to Help -> About Google Chrome -> Chrome will automatically look for updates(update Chrome to the latest version)
2. If your chrome version is already up to date -> Then you need to upgrade you chrome driver version
Here is the link: http://chromedriver.chromium.org/downloads
I encountered the same problem. I tried installing a downgraded version of Chrome (current stable was 74 and the driver required chrome version must be between 70-73) but I wasn't able to do so.
I found another way. This link will show you which version is compatible with your current google-chrome (to know your version the command is google-chrome --version)
This link will guide you as to how to install chrome driver with zip file. The commands are:
cd
wget <URL to zip file>
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/bin/chromedriver
sudo chown root:root /usr/bin/chromedriver
sudo chmod +x /usr/bin/chromedriver
In case the error comes No such file or directory: '/usr/lib/chromium-browser/chromedriver' OR the same error persists
Repeat the above procedure with the path /usr/lib/chromium-browser/chromedriver instead of /usr/bin/chromedriver
For me, google-chrome version 74 worked with ChromeDriver version 73
If you end up here and you're using Laravel / Dusk, try:
php artisan dusk:chrome-driver
Your chrome version is very old. Version 68 is not the latest version. For all operating systems, Chrome is currently in version 71+. Please see the list here.
Alternatively, this is the link for downloading older versions.
In Summary:
Find your chrome version (Help-> About Google Chrome)
Find your chromedriver version, if you already have one. (For me "chromedriver.exe -v" gave me the version on windows environment.)
Visit the official chrome webdriver page (http://chromedriver.chromium.org/downloads)
Download the chromedriver matching your chrome browser version, from the above download location.
Have a glance at the release notes on this download page towards lower section of the page, which gives an clear idea regarding which driver to use for which version of browser.
You can put the downloaded chromedriver binary in the path environment.
There you go. All the best!
Just download chromedriver extension 2.8 or 2.9 from here.
Extract it and add this extension to /usr/local/bin
I faced this issue due to mismatch of chromedriver and chrome version. I followed the below steps to resolve my issue:
1) First, find out which version of Chrome you are using. My Chrome version was 77.0.3865.90.
2) Take the Chrome version number, remove the last part, and append the result to URL "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_". For example, with Chrome version 77.0.3865.90, you'd get a URL "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_77.0.3865".
3) Use the URL created in the last step to retrieve the version of ChromeDriver to use. For example, the above URL will get your a file containing "77.0.3865.40". (The actual number may change in the future, of course.)
4) I then did :
webdriverdownloader chrome:77.0.3865.40 on my mac terminal.
After this your Chromedriver and Chrome version must be in sync and the issue should be fixed.
You have to match the chromedriver version number and your web browser chrome version ,
If both of the version match then it is best.
>
For Example -
1- your web browser chrome version is 77 ( For checking your web browser chrome version
got to your web browser help and then About Google Chrome there you will find
your web browser chrome version ) .
2- Now download same version here 77 chromedriver from https://chromedriver.chromium.org/downloads .
3- Make google chrome as your default web browser .
All done .
Your code will run fine.
from selenium import webdriver
driver=webdriver.Chrome("chromedriver.exe")
# Below line of code provide
driver.get('http://python.org')
html_doc=driver.page_source
print("Html code of http://python.org web page :",html_doc)