I have an electron app that uses the chromedriver package. I am also using selenium and the chromedriver needs to support the user's current chrome version because selenium needs to connect to a new browser session opened using the user's google chrome. The thing about chromedriver is that it is not going to support a Chrome session unless unless both the driver and the user's google chrome have the same version. Indeed, when I try to run chromedriver who's version is the not same as the user's Chrome version, I get the following error:
WebDriverError: unknown error: cannot connect to chrome at localhost:9222
from session not created: This version of ChromeDriver only supports Chrome version 101
Current browser version is 103.0.5060.114
I use the following command to start the google chrome session on Linux/Mac:
google-chrome --remote-debugging-port=9222 --user-data-dir="/user/data/dir"
How can I solve this issue? I have thought about if maybe I can set the version of the chromedriver programmatically when the electron app is launched. Would that work? Otherwise, is there a way to change the session's browser version?
Related
I am using PyCharm to run my robot framework-selenium scripts.
I am facing an issue
SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 91 Current browser version is 93.0.4577.63 with binary path
Attached are my settings.
How to upgrade chromedriver for Chrome version 93 or any other suggestion. I have 75 automation scripts and it is not feasible to add driver = chrome path in all the scripts.
Browser drivers
The general approach to install a browser driver is downloading a right driver, such as chromedriver for Chrome, and placing it into a directory that is in PATH
Drivers for different browsers can be found via Selenium documentation or by using your favorite search engine with a search term like selenium chrome browser driver. New browser driver versions are released to support features in new browsers, fix bug, or otherwise, and you need to keep an eye on them to know when to update drivers you use.
Alternatively, you can use a tool called WebdriverManagerwhich can find the latest version or when required, any version of appropriate webdrivers for you and then download and link/copy it into right location. Tool can run on all major operating systems and supports downloading of Chrome, Firefox, Opera & Edge webdrivers.
Here's an example:
pip install webdrivermanager
webdrivermanager firefox chrome --linkpath /usr/local/bin
Please go through, here, everything is documented here.
when i go to command prompt and type chromedriver -v:
ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945#{#614})
but when i try to run this code :
from selenium import webdriver
class InstaBot:
def __init__(self):
self.driver=webdriver.Chrome()
self.driver.get("www.instagram.com")
InstaBot()
it gives me error like this:
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
why this is happening i tried to remove selenium as well as chromedriver
and reinstall of version 79.0.3945 but when i run it ,it show this can only be run on version 80
my chrome version is 79.0.3945 which is lastest ,and version 80 chrome is chrome beta
This error message...
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
...implies that the ChromeDriver v80.0 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 mentioned about using chromedriver=79.0.3945.36 and the release notes of chromedriver=79.0 clearly mentions the following :
Supports Chrome v79
Presumably you are using chrome v79.0 browser.
So, it's quite evident your have chromedriver=80.0 present within your system which is also within the system PATH variable and is invoked while you:
self.driver=webdriver.Chrome()
Solution
There are two solutions:
Either you upgrade chrome to Chrome Version 80.0 level. (as per ChromeDriver v80.0 release notes)
Or you can override the default chromedriver v80.0 binary location with chromedriver v79.0 binary location as follows:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://google.com/')
You can find a detailed discussion in Ubuntu: selenium.common.exceptions: session not created: This version of ChromeDriver only supports Chrome version 79
Additional Considerations
Ensure to:
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.
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
Use Bonigarcia plugin in project. After that it will manage all driver by itself.It reads chrome version and instantiate driver accordingly.
for help follow my post :
https://www.linkedin.com/pulse/webdrivermanager-bonigarcia-rohan-ravi-yadav/
or original git link/post
https://github.com/bonigarcia/webdrivermanager
If any help required , Let me know
I have Ux Automation test project where in I am using the NuGet for Selenium.Chrome.WebDriver. The Agent in the release pipeline has below versions of chrome & WebDriver
Google Chrome
version:
75.0.3770.100
Selenium Web Drivers
Chrome Driver
version:
75.0.3770.90
Environment:
ChromeWebDriver: location of chromedriver.exe
I have tried check-in the project with 75 & 76 NuGet reference. However, I am getting below error in both cases.
System.InvalidOperationException: session not created: This version of ChromeDriver only supports Chrome version 76 (SessionNotCreated)
Which version it is complaining for?
This error message...
System.InvalidOperationException: session not created: This version of ChromeDriver only supports Chrome version 76 (SessionNotCreated)
...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:
Though you mentioned about using chromedriver=75.0.3770.90 there may be multiple instances of chromedriver being present in your system and the the version of the chromedriver which is effective in your tests is chromedriver=76.0
Release Notes of chromedriver=76.0 clearly mentions the following :
Supports Chrome version 76
Presumably you are using chrome= 75.0.
Release Notes of ChromeDriver v75.0 clearly mentions the following :
Supports Chrome 75
So there is a clear mismatch between the ChromeDriver v76.0 and the Chrome Browser v75.0
Solution
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v79.0.3945.36 level.
Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.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 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
I had built a web-scraper with an old version of chrome and it was working well and then chrome autoupdated itself with version 69.0.3497.81 and now any website doesn't seem to recognise the web browser while scraping. Is there a version if ChromeDriver that works well? I also tried downgrading chrome to previous versions, but doesn't seem to work anymore
(Note:- I tried ChromeDriver 2.41 and it doesn't work right.)
Thanks in advance
To keep the ChromeDriver Version that works in sync with the respective Chrome Browser Version you can adopt the following strategy:
Keep Auto Update of Chrome Browser OFF
Identify your current Chrome Browser version.
As per the Release Notes of ChromeDriver download the respective ChromeDriver version from ChromeDriver - WebDriver for Chrome
As per best practices:
Keep your Test Environment always updated with the latest ChromeDriver.
Always keep the Chrome Browser updated to the latest GA release.
Note : Each version of ChromeDriver is released considering the support of the:
Latest Released GA version of Chrome Browser
Previous version of Chrome Browser
Next version of Chrome Browser
Here you can find a detailed discussion on How to work with a specific version of ChromeDriver while Chrome Browser gets updated automatically through Python selenium
Specific version of a ChromeDriver binary supports a specific range of Chrome Browser versions as below:
ChromeDriver v2.41 (2018-07-27)
Supports Chrome v67-69
ChromeDriver v2.40 (2018-06-07)
Supports Chrome v66-68
ChromeDriver v2.39 (2018-05-30)
Supports Chrome v66-68
ChromeDriver v2.38 (2018-04-17)
Supports Chrome v65-67
ChromeDriver v2.37 (2018-03-16)
Supports Chrome v64-66
ChromeDriver v2.36 (2018-03-02)
Supports Chrome v63-65
ChromeDriver v2.35 (2018-01-10)
Supports Chrome v62-64
ChromeDriver v2.34 (2017-12-10)
Supports Chrome v61-63
ChromeDriver v2.33 (2017-10-03)
Supports Chrome v60-62
ChromeDriver v2.32 (2017-08-30)
Supports Chrome v59-61
ChromeDriver v2.31 (2017-07-21)
Supports Chrome v58-60
ChromeDriver v2.30 (2017-06-07)
Supports Chrome v58-60
ChromeDriver v2.29 (2017-04-04)
Supports Chrome v56-58
Simply add you google account in the emulator and update google chrome from playstore to work it for latest chrome driver.
I am getting below Exception while running test scripts.
geb.driver.DriverCreationException: failed to create driver from callback 'script1501516684770944233575$_run_closure1#6601cc93'
java.lang.NoClassDefFoundError: Lorg/openqa/selenium/remote/html5/RemoteWebStorage;
failed to create driver from callback 'script1501516684770944233575$_run_closure1#6601cc93'
OS: Windows 10 64 bit
Chrome browser: v60 (latest one)
Selenium :-2.43.1
Chrome web driver:-2.24.417431
geb-version:0.10.0
geb-testng-version:0.13.1
geb-spoc-version:0.13.1
Thanks in Advance...!
This will be a version issue (your old web driver is not compatible with newer chrome versions). If you are using the latest version of chrome, I suggest moving to the latest version of selenium and chrome driver.
Infact one quick google suggests that I might be right: https://sites.google.com/a/chromium.org/chromedriver/downloads
Latest Release: ChromeDriver 2.31
Supports Chrome v58-60
This error can be thrown if you do not correctly define your chrome driver location when executing your tests.
Either in your GebConfig:
driver = {
System.setProperty('webdriver.chrome.driver', '/Users/foo/drivers/chromedriver')
new ChromeDriver()
}
Or in something like VM parameters if running from an intelliJ Run/Debug Configuration:
-Dbrowser=chrome -Dwebdriver.chrome.driver="/Users/foo/drivers/chromedriver/chromedriver.exe"
I was having this problem for a couple of days and finally understand the cause. This problem occurred for me on Jenkins when I am setting my browser to chrome or firefox and then trying to run my tests. It occurred due to browsers not installed on Jenkins machine. The drivers are present in the code but the browser should be installed on machine otherwise Geb will throw this error. Hope this helps.