How to address SessionNotCreatedException with latest chromedriver.exe? - selenium

I'm trying to run my selenium test with selenium server standalone but getting this exception even I already update chromedriver.exe to the last version 108
org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 99
And also running with selenium grid standalone but said
Starting ChromeDriver 99.0.4844.51
This is the part of the code whenever I get or receiving the error
System.setProperty(webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
And currently I was using this version of selenium
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
And in PowerShell already reviewed
PS C:> .\chromedriver.exe -v
ChromeDriver 108.0.5359.71 (1e0e3868ee06e91ad636a874420e3ca3ae3756ac-refs/branch-heads/5359#{#1016})
PS C:>

This log messages...
Starting ChromeDriver 99.0.4844.51
.
.
org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 99
...implies that your framework effectively still uses ChromeDriver v99.0.4844.51 where as the latest Google Chrome version is 109.0.5414.75
Solution
Download the matching ChromeDriver from ChromeDriver-Downloads and execute your tests.

Related

Chromedriver versions are labelled differently in chromium website and maven repository. Which one to consider for chromedriver?

I see chromedriver is available on https://sites.google.com/a/chromium.org/chromedriver/ and also on https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver.
However the versions are different in both cases.
In chromium website, it is mentioned as Current stable release: ChromeDriver 84.0.4147.30
In maven repository, it is mentioned as 4.0.0-alpha-6 as latest artifact.
Question: What is the difference between both and which one should be included as a project dependency for chromedriver.exe ? I am using a selenium java testng project.
You are partially correct as they are different.
The ChromeDriver you see at ChromeDriver - WebDriver for Chrome is the executable binary which we use most commonly as in:
Java:
System.setProperty("webdriver.chrome.driver","C:\\WebDrivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com/");
Python:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'C:/path/to/chromedriver.exe')
driver.get("https://www.google.com/")
Where as the installation of Selenium libraries for Selenium-Java clients can be done using maven as well just by adding the selenium-java dependency in your project pom.xml which would support running your automation project with all Selenium supported browsers:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.X</version>
</dependency>
But if you want to run tests only in a specific browser, e.g. Chrome, you can add the Chrome specific dependency in the project pom.xml file as follows:
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>4.0.0-alpha-6</version>
</dependency>
The artifacts within Selenium Chrome Driver is the Selenium bindings specifically for the ChromeDriver and google-chrome combo.
To understand these we need to first understand following:
ChromeDriver is a standalone server that implements the W3C WebDriver standard.
https://chromedriver.storage.googleapis.com/index.html is location of executables from google.
WebDriver is an open source tool for automated testing of webapps across many browsers. It provides capabilities for navigating to web pages, user input, JavaScript execution, and more.
https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver is location of mvn dependences to interact with ChromeDriver executable. So have selenium-chrome-driver ChromeDriver class
: A WebDriver implementation that controls a Chrome browser running on the local machine.
Some more good read links:
What we have in selenium-chrome-driver https://www.javadoc.io/static/org.seleniumhq.selenium/selenium-chrome-driver/4.7.2/index.html?org/openqa/selenium/chrome/ChromeDriver.html
WebDriver commands https://chromium.googlesource.com/chromium/src/+/master/docs/chromedriver_status.md
Change logs for JAVA in selenium versions https://github.com/SeleniumHQ/selenium/blob/trunk/java/CHANGELOG

SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81

I am currently new to robot framework.I am currently using latest window version of chrome and chromedriver which is 80 but when i try to run the test it gives the message "SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81" in pycharm but currently beta version of 81 is only available. I have tried uninstalling everthing and reinstalling it again but nothing works can anyone help me with this.Thank you!
Screenshots below:
I solved these kinds of problems using the webdrive manager.
You can automatically use the correct chromedriver by using the webdrive-manager.
Install the webdrive-manager:
pip install webdriver-manager
Then use the driver in python as follows
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
This answer is taken from https://stackoverflow.com/a/52878725
Do below steps :
Check the version of chrome browser.
download chromedriver of same version from https://sites.google.com/chromium.org/driver/home
Give correct path in the pycharm and run the code.
I got the same message on MacOS:
"selenium.common.exceptions.SessionNotCreatedException: Message:
session not created: This version of ChromeDriver only supports Chrome
version 81"
Then I run this command, it's gone:
# Homebrew 3
brew upgrade chromedriver
# Homebrew < 3
brew cask upgrade chromedriver
This error message...
SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81
...implies that the ChromeDriver v81 was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser where is version is other then 81.0.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You mentioned about using chromedriver=80 and chrome=80 but somehow while your program execution ChromeDriver v 81.0 is used.
So, it's quite evident your have chromedriver=81.0 present within your system and is present within the system PATH variable which gets invoked while you:
driver = webdriver.Chrome()
Solution
There are two solutions:
Either you upgrade chrome to Chrome Version 81.0 level. (as per ChromeDriver v81.0 release notes)
Or you can override the default chromedriver v81.0 binary location with chromedriver v80.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/')
Reference
You can find a couple of relevant discussions in:
How to work with a specific version of ChromeDriver while Chrome Browser gets updated automatically through Python selenium
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80
Ubuntu: selenium.common.exceptions: session not created: This version of ChromeDriver only supports Chrome version 79
First of all check latest Chrome version (This is your browser Chrome version) link
Download same version of Chrome Web Driver from this link
Do not download latest Chrome Web Driver if it does not match your Chrome Browser version.
Note: When I write this message, latest Chrome Browser version is 84 but latest Chrome Driver version is 85. I am using Chrome Driver version 84 so that Chrome Driver and Chrome Browser versions are the same.
Go to your Chrome settings -> About Chrome -> Check version
and download chromedriver from Below according to your Chrome version
https://chromedriver.chromium.org/downloads
this works for me
brew cask upgrade chromedriver
Above is deprecated on MacOs, use:
brew install chromedriver (if not already installed)
brew upgrade chromedriver
Chrome version is updating everyday so you need use exact chromedriver version according chrome version
https://chromedriver.chromium.org/downloads in this website you can download chromedrivers
The solution (at least on OSX) is:
Download the latest chromedriver file.
Unzip the downloaded file.
Search the location of the old chromedriver file on your computer and replace it with the new chromedriver file.
Right-click the chromedriver file and click open. Do not double click as Mac will not open it the proper way.
Once the file runs for the first time, you can close it and the update will have taken place.
Your Chrome Driver version needs to match your Chrome Browser version
Get you Chrome Browser version, by typing chrome://version
enter image description here
Download Chrome Driver version that matches you Chrome Browser version, form this website
https://chromedriver.chromium.org/downloads
If you are getting this error when you run stuffs on automated cluster and you are downloading the stable version of the google chrome every time then you can use the below shell script to download the compatible version of the chrome driver dynamically every time even if the stable version of the chrome gets updated.
%sh
#downloading compatible chrome driver version
#getting the current chrome browser version
**chromeVersion=$(google-chrome --product-version)**
#getting the major version value from the full version
**chromeMajorVersion=${chromeVersion%%.*}**
# setting the base url for getting the release url for the chrome driver
**baseDriverLatestReleaseURL=https://chromedriver.storage.googleapis.com/LATEST_RELEASE_**
#creating the latest release driver url based on the major version of the chrome
**latestDriverReleaseURL=$baseDriverLatestReleaseURL$chromeMajorVersion**
**echo $latestDriverReleaseURL**
#file name of the file that gets downloaded which would contain the full version of the chrome driver to download
**latestDriverVersionFileName="LATEST_RELEASE_"$chromeMajorVersion**
#downloading the file that would contain the full release version compatible with the major release of the chrome browser version
**wget $latestDriverReleaseURL**
#reading the file to get the version of the chrome driver that we should download
**latestFullDriverVersion=$(cat $latestDriverVersionFileName)**
**echo $latestFullDriverVersion**
#creating the final URL by passing the compatible version of the chrome driver that we should download
**finalURL="https://chromedriver.storage.googleapis.com/"$latestFullDriverVersion"/chromedriver_linux64.zip"**
**echo $finalURL**
**wget $finalURL**
I was able to get the compatible version of chrome browser and chrome driver using the above approach when running scheduled job on the databricks environment and it worked like a charm without any issues.
Hope it helps others in one way or other.
With Laravel (PHP) you can fix this with:
php artisan dusk:install
It will download and install the new driver.
Documentation: https://laravel.com/docs/9.x/dusk#installation
The case when your Chrome is in the middle of its update also causes this exception. In my case chromedriver was already updated, while the chrome itself was v81 instead of v83.
You can also download the correct chromedriver version from:
https://chromedriver.chromium.org/downloads
https://chromedriver.storage.googleapis.com/index.html?path=81.0.4044.138/
I too had a similar problem. And I've got a solution .. Download the matching chromedriver, and place the chromedriver under the /usr/local/bin path. It works.
The way I solved this issue was quite simple, I checked my chrome version and I had an older chromedriver in my PATH variable, so I downloaded the chromedriver version that matched my browser and replaced the old one in the PATH, so when the webdriver module looked for a chromedriver in my PATH, it would find the matching version
I had already been running a local server at the same port the session wanted to run on, and this caused the error. Shutting down that local server fixed this for me.
You need to install webdriver manager. Make sure webdriver manager it is also updated.
If you use npm:
npm install -g webdriver-manager
webdriver-manager update
If you're getting this error in Visual Studio 2019 and using Selenium.WebDriver.ChromeDriver by jsakamoto, check the version you're referencing in the packages.config file.
<package id="Selenium.WebDriver.ChromeDriver" version="89.0.4389.2300" targetFramework="net45" />
Update your NuGet package to the appropriate version and resolve the issue.
I resolved this issue by simply running Firefox (geckodriver) instead of Chrome:
rsDriver(browser = "firefox")
I got this error after a recent chrome upgrade, and also I recently updated my Mac to Big Sur. Seems cask is not part of brew command, need to use it separately.
brew install --cask chromedriver
You can handle this exception
from selenium.common.exceptions import SessionNotCreatedException
Add this function
def update_chrome():
try:
print("Updating chrome driver")
download_chrome = "wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
unpack_chrome = "sudo dpkg -i google-chrome-stable_current_amd64.deb"
install_chrome = "sudo apt-get -f install"
file_path = os.path.join(os.environ['HOME'], "google-chrome-stable_current_amd64.deb")
if os.path.isfile(file_path):
print("{} found\nremoving {}".format(file_path, file_path))
os.remove(file_path)
else:
print("File does not exist {}".format(file_path))
old_chrome_ver = os.popen("/usr/bin/google-chrome --version").read().strip('Google Chrome ').strip().split(".")[0]
print("Current Chrome version: {}".format(old_chrome_ver))
os.system(command=download_chrome)
sleep(2)
os.system(command=unpack_chrome)
sleep(5)
os.system(command=install_chrome)
crnt_chrome_ver = os.popen("/usr/bin/google-chrome --version").read().strip('Google Chrome ').strip().split(".")[0]
print("Current Chrome version: {}".format(crnt_chrome_ver))
if crnt_chrome_ver == old_chrome_ver:
print("Chrome version is same as before")
elif crnt_chrome_ver > old_chrome_ver:
print("Chrome version is updated from {} to {}".format(old_chrome_ver, crnt_chrome_ver))
return True
except Exception as e:
print("Error while updating chrome: {}".format(e))
return False
then call this function
try:
# Your code here
except SessionNotCreatedException as snce:
print("Session not created: {}".format(snce))
chrome_update_result = False
if recurrences == 0:
chrome_update_result = update_chrome()
if chrome_update_result:
recurrences += 1
print("Chrome updated successfully")
erisapedia_bot(state, download_dir)
return True
else:
print("Chrome update failed")
return False
What worked for me is this command:
pip install chromedriver-binary==your_chrome_version
This will uninstall the current chrome-driver that you have installed and will install a chrome-driver that matches your chrome version.
The solution is:-
Check out the chrome version of your chrome.From chrome://settings/help
Check out which version of ChromeDriver is compatible with your current
chrome version from here
download the compatible one and replace the existing ChromeDriver with
a new ChromeDriver.
Now run the code
It didn't feel like folks were answering the issue here which is: being on the latest version of beta Chrome/Chromium and not seeing the matching chromedriver version
For example, currently as of writing this, Chromium for Mac is Version 86.0.4190.0 (Developer Build) (64-bit) however the latest chromedriver versions listed are
Current stable release: ChromeDriver 83.0.4103.39
Current beta release: ChromeDriver 84.0.4147.30
If you go to https://chromedriver.chromium.org/downloads/version-selection, they provide some pointers on getting a compatible version. One of the last lines near the end mentions trying the ChromeDriver Canary build which leads to how to get it from Chromium browser snapshots.
Of course this goes without saying that using the latest experimental version is likely to have bugs
I faced this problem even after using webdriver manager. I was able to resolve the issue after specifying the exact version of chromedriver that I needed in the webddriver manager.
I was using chrome version 84 and the webdriver manager was installing the latest version of chromedriver, which was 85.0.4183.38.
I made webdriver manager to open the chromedriver version 84.0.4147.30 by writing the following command.
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager(84.0.4147.30).install())
Referring to #dylanvanw answer. You might still out of luck. I found that you might have a different path that you have installed Python. In my case, I have to move Chromedriver.exe from the cache path (C:\Users\Poom.wdm\drivers\chromedriver\win32\84.0.4147.30) to C:\Python38 then it work!
Steps I took to make it work
Check your current Chrome version e.g. 81
Goto tools/nuget package manager
Select selenium chrome driver
upgrade/downgrade to the same Chrome-version you have.
Restarting the application should work.
I found a workaround to download latest version of ChromeDriver via WebDriverManager
You could try something like,
WebDriver driver = null ;
boolean oldVersion = true;
String chromeVersion = "";
try {
try{
FileReader reader = new FileReader("chromeVersion.txt") ;
BufferedReader br = new BufferedReader(reader) ;
String line;
while ((line = br.readLine()) != null){
chromeVersion = line.trim();
}
reader.close();
} catch (IOException e ) {}
WebDriverManager.chromedriver().version(chromeVersion).setup();
driver = new ChromeDriver() ;
} catch (Exception e) {
oldVersion = false;
String err = e.getMessage() ;
chromeVersion = err.split("version is")[1].split("with binary path")[0].trim();
try{
FileWriter writer = new FileWriter("chromeVersion.txt", true) ;
writer.write(chromeVersion) ;
writer.close();
} catch (IOException er ) {}
}
if (!oldVersion){
WebDriverManager.chromedriver().version(chromeVersion).setup();
driver = new ChromeDriver() ;
}
driver.get("https://www.google.com") ;
I got this error when the chrome driver was not closed properly. Eg, if I try to find something and click it and it doesn't exist, the driver throws an exception and the thread ended there ( I did not close the driver ).
So, when I ran the same method again later where I had to reinitialize the driver, the driver didn't initialize and it threw the exception.
My solve was simply to wrap the selenium tasks in a try catch and close the driver properly

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80

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

HOOK-ERROR in after_step: TimeoutException: Message: timeout

Sometimes, when my script is run by jenkins i get an error:
HOOK-ERROR in after_step: TimeoutException: Message: timeout
(Session info: chrome=69.0.3497.92)
(Driver info: chromedriver=2.35.528139
(47ead77cb35ad2a9a83248b292151462a66cd881),platform=Linux 4.4.0-128-generic x86_64)
i cannot reproduce this situation on my local machine. Do you have any idea how can i check and fix it?
This error message...
HOOK-ERROR in after_step: TimeoutException: Message: timeout
(Session info: chrome=69.0.3497.92)
(Driver info: chromedriver=2.35.528139
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser 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.35
Release Notes of chromedriver=2.35 clearly mentions the following :
Supports Chrome v62-64
You are using chrome=69.0
Release Notes of ChromeDriver v2.43 clearly mentions the following :
Supports Chrome v69-71
So there is a clear mismatch between the ChromeDriver v2.35 and the Chrome Browser v69.0
Solution
Upgrade JDK to recent levels JDK 8u191.
Upgrade Selenium to current levels Version 3.14.0.
Upgrade ChromeDriver to current ChromeDriver v2.42 level.
Keep Chrome version between Chrome v69-71 levels. (as per ChromeDriver v2.43 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.
Execute your #Test.

which firefox version is compatible with selenium 3.5.0?

I tried with Selenium 3.5.3 GeckoDriver 0.19 Firefox 55 but getting below exception:
Error: org.openqa.selenium.WebDriverException: browser name not boolean
Code :
DesiredCapabilities cap = DesiredCapabilities.firefox();
WebDriver driver = null;
System.setProperty("webdriver.gecko.driver", "<path to gecko>\geckodriver.exe");
cap.setBrowserName("firefox");
URL sURL= null;
cap.setCapability("firefox_binary", "<FIREFOX_PATH>"));
//Grid
sURL = new URL("http://localhost:5555/wd/hub");
driver = new RemoteWebDriver(sURL, cap);
Also saw this thread https://seleniumhq.wordpress.com/2017/08/09/firefox-55-and-selenium-ide/ that selenium ide would not be supported anymore in Firefox 55. Whether selenium jar would be still supported?
It was a bad news for the tester community since Selenium IDE no long works from Firefox 55 onwards. Now you have 2 choices:
1- Try with previous version of firefox (Temporary solution)
2- Use Selenium IDE alternatives (Highly Recommended)
I recommend you to use Firefox 54.0 and geckodriver v0.18.0.
Actually this links regarding Selenium IDE. You can use firefox 55 also.