简体   繁体   中英

How do i fix my chromedriver if its not compatible with chrome version?

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

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/")

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM