6

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
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Talha Tutorials
  • 93
  • 1
  • 1
  • 12
  • you could lookup a chromedriver that supports your version of chrome or just downolad Chrome in version 85 – icecube Jan 10 '21 at 16:41
  • 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. – kwkt Jan 10 '21 at 16:42
  • @kwkt I wouldn't recommed this as the older version may have security flaws. I'd keep the Chrome browser updated. – Leemosh Jan 10 '21 at 16:50

2 Answers2

8

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/")
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
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")
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Leemosh
  • 883
  • 6
  • 19
  • 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 path – Talha Tutorials Jan 10 '21 at 17:13
  • Well, what is your Chrome browser version? – Leemosh Jan 10 '21 at 17:23
  • chrome version 87.0.4280.88, check the updated question it shows the error mentioned – Talha Tutorials Jan 10 '21 at 17:24
  • Good! Then here is your chromedriver version https://chromedriver.storage.googleapis.com/index.html?path=87.0.4280.88/ – Leemosh Jan 10 '21 at 17:26
  • 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) – Leemosh Jan 10 '21 at 17:27
  • Just copy the executable chromedriver to the folder with your python file and then call `driver = webdriver.Chrome(executable_path="chromedriver.exe")` – Leemosh Jan 10 '21 at 17:35
  • 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? – Talha Tutorials Jan 10 '21 at 17:44
  • `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. – Leemosh Jan 10 '21 at 17:52
  • 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) – Talha Tutorials Jan 10 '21 at 17:53
  • Updated the answer. You should show your code and directories as well if you need additional help. – Leemosh Jan 10 '21 at 18:04