How to fix the chromedriver if its not compatible with chrome version?
J

5

11

The Following Error is given when i run my code:

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

I have tried to download a newer version of chromdriver but it still gives me the same error. I have tried to replace the current chromedriver that's running and the one I downloaded recently but it still gave the same error, so I downloaded the compatible version of chromdriver, and then I used this line of code:

driver = webdriver.Chrome(executable_path='D:\talha\Documents\Projects For Portfolio\SmmoBot\chromedriver_win32\chromedriver.exe')

But this returns the following error:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH
Joviality answered 10/1, 2021 at 16:40 Comment(3)
you could lookup a chromedriver that supports your version of chrome or just downolad Chrome in version 85Tildi
Chromedriver usually runs with an older version of Chrome. I think your best course of action is to uninstal Chrome, then reinstall the supported version.Coolie
@kwkt I wouldn't recommed this as the older version may have security flaws. I'd keep the Chrome browser updated.Downstage
B
12

You can download and use the latest ChromeDriver automatically using .

This can be achieved by installing the webdriver-manager using the command:

pip install webdriver-manager
  • Implemention through code:

    from selenium import webdriver
    from webdriver_manager.chrome import ChromeDriverManager
    
    driver = webdriver.Chrome(ChromeDriverManager().install())
    driver.get("https://www.google.com/")
    
Blowtorch answered 10/1, 2021 at 23:34 Comment(5)
This is amazing! is there a similar solution for Java and Mavin?Brittenybrittingham
@MosheSlavin Yes, there areBlowtorch
Yes! I have found this repo I'm working on implementing it in my projects. ThanksBrittenybrittingham
@MosheSlavin Actually I had an answer with all the details and atm I'm unable to locate the discussion :/Blowtorch
i must add that the same problem happened again but this time i was using visual studio code and it automatically detected that selenium needed to be updated and updated it for me! i highly recomend visual studio code for intermediate programmers.Joviality
D
0

Your version of Chrome and Chromedriver has to be the same. Best way is to keep your Chrome browser updated and just download newest version of chromedriver.

You have 2 options:

Either download the version of chromedriver fitting your actual chrome browser

or

preferred way update your chrome browser and download fitting version of chroemdriver

My version of chrome is 87.0.4280.141

My version of chromedriver is 87.0.4280.88

My chromedriver is in the same folder as my script and this is a working code.

from selenium import webdriver

driver = webdriver.Chrome(executable_path="chromedriver.exe")
driver.get("https://google.com")
Downstage answered 10/1, 2021 at 16:42 Comment(10)
my chrome browser is up to date its my chromedriver, my chromedriver is apparently out of date but when i download a newest version it does not work and says it needs to be added to pathJoviality
Well, what is your Chrome browser version?Downstage
chrome version 87.0.4280.88, check the updated question it shows the error mentionedJoviality
Good! Then here is your chromedriver version chromedriver.storage.googleapis.com/…Downstage
Don't forget you are downloading a zip file, so extract and replace your actual chromedriver with new one. Then your code should be working. (or at least give a different error)Downstage
Just copy the executable chromedriver to the folder with your python file and then call driver = webdriver.Chrome(executable_path="chromedriver.exe")Downstage
I cant seem to find my old chromedriver for some reason is there anyway i can get python to print out the directory path of the chromedriver?Joviality
driver = webdriver.Chrome(executable_path='D:\talha\Documents\Projects For Portfolio\SmmoBot\chromedriver_win32\chromedriver.exe') well what is this then? You are defining the path where is your chromedriver. Put it in your directory - where the python script is and run what I said in the previous comment.Downstage
this is the new version of chromedriver that i downloaded, i put it into the same folder as the python file and i tried to use executable_path to reference the chromdriver that i wanted to use but it didnt work and it says i need to add it to path(also i tried to do the thing you told me in your previous comment it gives the same error)Joviality
Updated the answer. You should show your code and directories as well if you need additional help.Downstage
I
0

You can easily use the file named getDriver.py on this repo to get the correct version installed on the first run. It is working just fine untill now. https://github.com/DevGadBadr/getSuitableChromeDriver

Id answered 28/12, 2023 at 10:7 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Theda
H
0

If you need to use Options like me:

from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--headless=new")
servico = Service(ChromeDriverManager().install())

driver = webdriver.Chrome(service=servico, options=chrome_options)

driver.get(url_desejada)
Heathenish answered 22/3 at 20:29 Comment(0)
E
0

I'm pretty sure that with the latest version of Selenium, if you don't specify a location for the chrome driver.exe file, Selenium will automatically manage it for you. It's a feature that recently came out. For example, on my machine:

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://www.google.com")
driver.quit()

...is all I need to access a web page. I don't have any version of chromedriver.exe installed. Selenium manages this. You just need the latest version of Selenium.

***NOTE: This question is old. The automatic management of chromedriver that Selenium has came out very recently.

Endoblast answered 23/3 at 1:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.