I just uninstalled Chrome because it was acting strange (fixed now) and after this Selenium in Python is not able to identify the Chrome driver binary, which is extremely strange because it should be completely unaffected and it is in a different location and a different version from the chrome I use on my desktop, code is as follows and has worked for years now.
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--load-extension='+exension_path)
driver = webdriver.Chrome(executable_path=chrome_driver_folder,options=chrome_options)
Anyone has any idea what on earth is going on? I get the follow error:
WebDriverException: Message: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 10.0.18362 x86_64)
This error message...
WebDriverException: Message: unknown error: cannot find Chrome binary (Driver info: chromedriver=2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab),platform=Windows NT 10.0.18362 x86_64)
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.40
Release Notes of chromedriver=2.40 clearly mentions the following :
Supports Chrome v66-68
As you have uninstalled Chrome and reinstalled presumably you are using the latest chrome=85.0
Release Notes of ChromeDriver v85.0 clearly mentions the following :
Supports Chrome version 85
So there is a clear mismatch between ChromeDriver v2.40 and the Chrome Browser v85.0
Solution
Ensure that:
Selenium is upgraded to current released Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v85.0 level.
Chrome is updated to current Chrome Version 85.0 level. (as per ChromeDriver v85.0 release notes)
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
In order to have a clean code and to stop track the chrome path/version, I recommend to you to use webdriver_manager
Install it
pip install webdriver_manager
and use it like this
from webdriver_manager.chrome import ChromeDriverManager
options = webdriver.ChromeOptions()
chrome_options.add_argument('--load-extension='+exension_path)
driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), options=options)
but if don't want to use it here is the code for local browser
chrome_options = Options()
chrome_options.add_argument('--load-extension='+exension_path)
chrome_options.binary_location = 'YOUR_PATH'
driver = webdriver.Chrome(executable_path=os.path.abspath(“chromedriver"), chrome_options=chrome_options)
but I totally recommend using the first version.
Related
I installed selenium/standalone-chrome in docker, and the version is 4.1.2. But when I run my python code get bellow error:
My selenium/standalone-chrome in docker:
My python code:
def demo():
options = Options()
options.add_argument('--headless')
options.add_argument('--disable-gpu')
driver = webdriver.Remote(
command_executor="http://localhost:4444/wd/hub",
desired_capabilities=DesiredCapabilities.CHROME
)
driver.get("https://www.google.com/")
print(driver.current_url)
driver.quit()
Could anyone give me a favor on this issue? Thanks.
You can fix your code by only adding this line to your code
options.set_capability("browserVersion", "98")
This error message...
selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. ... Response code 500.
.
Driver info: driver.version: unknown
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. google-chrome session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chrome=98.0
Release Notes of ChromeDriver v98.0 clearly mentions the following :
Supports Chrome version 98
But your chromedriver version is not getting detected.
Driver info: driver.version: unknown
So most possibly there is a mismatch between chromedriver version and the chrome=98.0
Solution
Ensure that:
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).
my code is as follows:
from selenium import webdriver
driver = webdriver.Chrome(executable_path="/webdriver/chromedriver.exe")
driver.get('http://google.com/')
When I run the program, the browser opens for half a second then closes down and gives the error
Message: session not created: This version of ChromeDriver only supports Chrome version 85
I'm using this version of chromedriver for my program: https://chromedriver.storage.googleapis.com/index.html?path=85.0.4183.38/
Any help is appreciated.
This error message...
Message: session not created: This version of ChromeDriver only supports Chrome version 85
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using the latest chrome=84.0
Release Notes of ChromeDriver v84.0 clearly mentions the following :
Supports Chrome version 84
Possibly you have downloaded chromedriver=85.0
Release Notes of chromedriver=85.0 clearly mentions the following :
Supports Chrome version 85
So there is a clear mismatch between Chrome Browser v84.0 and ChromeDriver 85.0
Solution
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v84.0 level.
Chrome is updated to current Chrome Version 84.0 level. (as per ChromeDriver v84.0 release notes)
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Chrome browser are updating time to time so you need to use exact driver exe according to your browser version please check your browser version and download driver exe based to match to your browser version in https://chromedriver.chromium.org/downloads and set path and refresh project and rerun
driver.get('http://google.com/')
insted of this single quotation use below double quotation
driver.get("http://google.com/")
So I'm working on a script that scrapes some data from a dynamic webpage and commits it to my database tables. For this, I've used Selenium in Python. It all worked perfectly fine until I restarted my system. Now chrome only works in headless mode and when I comment out that option so that I get to see an actual window of the chrome browser, I get this error
selenium.common.exceptions.WebDriverException: Message: unknown error:
Chrome failed to start: exited abnormally. (unknown error:
DevToolsActivePort file doesn't exist) (The process started from
chrome location /usr/bin/google-chrome is no longer running, so
ChromeDriver is assuming that Chrome has crashed.)
Solutions tried:
cross-checked the path of my chrome-binaries and it is valid
changed the order of adding options
uninstalled chrome and reinstalled it again
deleted the chromedriver and downloaded it again
restarted my system twice
googled the error and tried the solutions
EDIT: I have already tried adding the --no-sandbox option before commenting it out here as shown in the snapshot
One thing I would want to mention is that my root space is quite less and only 340 mb of free space is left. Does that affect?
To see an actual window of the chrome browser removing the argument -headless is perfect.
However, I would suggest to remove all the unwanted options and execute your test with the minimal lines of code as follows:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('start-maximized')
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=chrome_options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get("http://google.com/")
In case you see the error as:
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
You may need to add the argument --no-sandbox.
So the solution is to add back the argument:
chrome_options.addArguments("--no-sandbox");
chrome_options.addArguments("--disable-dev-shm-usage");
You can find a detailed discussion in WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
Additional considerations
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v83.0 level.
Chrome is updated to current Chrome Version 83.0 level. (as per ChromeDriver v83.0 release notes)
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test as non-root user.
Reference
You can find a detailed discussion in:
Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed
I am currently using Chrome 75 and I've downloaded the compatible Chromedriver for linux. I've also added it to the PATH variable. However, when I attempt initializing a driver with driver = webdriver.Chrome() I get the following error:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 76
What I get from this message is that my Chromedriver is ment for Chrome version 76, but both my Chromedriver and Chrome browser are version 75.
I even tried deleting the Chromedriver completely from my files and I still get the same error message
This error message...
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 76
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your code trials and the error stack trace would have helped us to debug the issue in a better way. Though you mentioned about compatible Chromedriver for linux but your program while in execution picks up the ChromeDriver v76.0.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Release Notes of chromedriver=76.0 clearly mentions the following :
Supports Chrome version 76
Solution
Ensure you have:
Deleted all the existing different versions of Chromedriver from your system.
ChromeDriver is updated to current ChromeDriver v76.0 level.
Additionally, ensure you pick up the latest release of ChromeDriver v76.0 i.e. ChromeDriver v76.0.3809.126.
Chrome is updated to current Chrome Version 76.0 level. (as per ChromeDriver v76.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
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 relevant detailed discussion in:
How to work with a specific version of ChromeDriver while Chrome Browser gets updated automatically through Python selenium
This error implement:
You need to download your version of chrome driver:
You can download your version of chrome driver via clicking here:
https://chromedriver.storage.googleapis.com/index.html?path=75.0.3770.140/
I have written a python script that does some tasks in the browser (using Selenium), which works fine in Windows. Now I am trying to now get it onto my Raspberry Pi.
I did a lot of searching to find the best way to get this to work with Chromium. The best I could find was at this Reddit Link.
The problem is that I cannot find a chromedriver that jives with my version of Chromium (version 56.0.2924.84). And when I do apt-get upgrade it advises me that I have the newest version of Chromium. I've tried chromedriver versions 53 through 65 by downloading from this Launchpad Link.
So when I run the following
from selenium import webdriver
driver_path = 'usr/lib/chromium-browser/chromedriver'
driver = webdriver.Chrome(driver_path)
I get this error for chrome drivers > 58
selenium.common.exceptions.SessionNoteCreatedException: Message: session not
created exception: Chrome version must be >= 59.0.3071.0
(Driver info: chromedriver=2.43,platform=Linux 4.9.35-v7+ armv7l)
or this error for chrome drivers < 58
selenium.common.exceptions.WebDriverException: Message:
Service /usr/lib/chromium-browser/chromedriver unexpectedly exited. Status code was: 127
any help here would be appreciated
As per your question your Chromium binary is of version 56.0.2924.84. So keeping this constraint in consideration the solution would be to download either of the following ChromeDriver version from ChromeDriver Google Storage
ChromeDriver v84: Supports Chrome v84
ChromeDriver v83: Supports Chrome v83
ChromeDriver v82: Was intentionally skipped
ChromeDriver v81: Supports Chrome v81
ChromeDriver v80: Supports Chrome v80
ChromeDriver v79: Supports Chrome v79
ChromeDriver v78: Supports Chrome v78
ChromeDriver v77: Supports Chrome v77
ChromeDriver v76: Supports Chrome v76
ChromeDriver v75: Supports Chrome v75
ChromeDriver v74: Supports Chrome v74
ChromeDriver v73: Supports Chrome v73
ChromeDriver v2.46: Supports Chrome v71-73
ChromeDriver v2.46: Supports Chrome v71-73
ChromeDriver v2.45: Supports Chrome v70-72
ChromeDriver v2.44: Supports Chrome v69-71 (same as ChromeDriver 2.43, but with additional bug fixes)
ChromeDriver v2.43: Supports Chrome v69-71
ChromeDriver v2.42: Supports Chrome v68-70
ChromeDriver v2.41: Supports Chrome v67-69
ChromeDriver v2.40: Supports Chrome v66-68
ChromeDriver v2.39: Supports Chrome v66-68
ChromeDriver v2.38: Supports Chrome v65-67
ChromeDriver v2.37: Supports Chrome v64-66
ChromeDriver v2.36: Supports Chrome v63-65
ChromeDriver v2.35: Supports Chrome v62-64
ChromeDriver v2.34: Supports Chrome v61-63
ChromeDriver v2.33: Supports Chrome v60-62
ChromeDriver v2.32: Supports Chrome v59-61
ChromeDriver v2.31: Supports Chrome v58-60
ChromeDriver v2.30: Supports Chrome v58-60
ChromeDriver v2.29: Supports Chrome v56-58
ChromeDriver v2.28: Supports Chrome v55-57
ChromeDriver v2.27: Supports Chrome v54-56
Note: A few months ago, Chromium Team made a preliminary announcement that ChromeDriver's versioning model will be changing. Chromium Team is moving forward with the plan. Specifically, ChromeDriver 2.46 will be the last release carrying the major version of 2. Future ChromeDriver releases will carry a version number similar to Chrome release. We will start with a release of ChromeDriver 73 next week, before the Beta release of Chrome 73.
Here is how the new release model will work:
ChromeDriver will be using the same version number scheme as Chrome. See https://www.chromium.org/developers/version-numbers for more details.
Each version of ChromeDriver will support Chrome with matching major, minor, and build version numbers. For example, upcoming ChromeDriver 73.0.3683.* will support all Chrome versions that start with 73.0.3683.
Before a new major version of Chrome goes to Beta, a matching version of ChromeDriver will be released. For example, a new version of ChromeDriver will be release next week to match the Beta release of Chrome m73.
After the initial release of a new major version, we will release patches as needed. These patches may or may not coincide with updates to Chrome.
ChromeDriver for Raspberry Pi
As you are using Raspberry Pi you need to download the arm format of ChromeDriver from this link and use it within your program.
Additional Considerations
Upgrade Selenium to current levels Version 3.11.0.
Upgrade ChromeDriver as per the above discussion.
Keep Chrome version at Chrome v56.x levels. (as per the discussion)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test.
Before: You should download binary chromedriver, unzip it somewhere in you PC and set path to this driver like this:
webdriver.Chrome('/home/user/drivers/chromedriver')
ChromeDriverManager(path=custom_path).install()
It’s boring!!! Moreover every time the new version of driver released, you should go and repeat all steps again and again.
With webdriver manager, you just need to do two simple steps:
Install manager:
pip install webdriver-manager
Use with Chrome:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
Use with Chromium:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.utils import ChromeType
driver = webdriver.Chrome(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install())
Use with FireFox:
from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager
driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
Use with IE:
from selenium import webdriver
from webdriver_manager.microsoft import IEDriverManager
driver = webdriver.Ie(IEDriverManager().install())
Use with Edge:
from selenium import webdriver
from webdriver_manager.microsoft import EdgeChromiumDriverManager
driver = webdriver.Edge(EdgeChromiumDriverManager().install())
Use with Opera:
from selenium import webdriver
from webdriver_manager.opera import OperaDriverManager
driver = webdriver.Opera(executable_path=OperaDriverManager().install())
Note
If the Opera browser is installed in a location other than C:/Program Files or C:/Program Files (x86) on windows and /usr/bin/opera for all unix variants and mac, then use the below code:
from selenium import webdriver
from webdriver_manager.opera import OperaDriverManager
options = webdriver.ChromeOptions()
options.add_argument('allow-elevated-browser')
options.binary_location = "C:\\Users\\USERNAME\\FOLDERLOCATION\\Opera\\VERSION\\opera.exe"
driver = webdriver.Opera(executable_path=OperaDriverManager().install(), options=options)