[Selenium] The latest version of chromedriver does not match the automatic update version of Chrome

1. Check the chromedriver version

When using Selenium, you need to download chromedriver
1. First, check that my Chrome browser version has been automatically updated to 116:

insert image description here

2. Find the corresponding chromedriver version: http://chromedriver.storage.googleapis.com/index.html
found that the latest version is only up to 114:
insert image description here
chromedriver does not match the Chrome version and there is no chromedriver that matches the latest Chrome version.
So consider downgrading your Chrome version and disabling automatic updates.

2. Downgrade the Chrome browser and disable automatic updates

1. First uninstall the Chrome browser and related data.
2. Then search for previous versions: https://www.slimjet.com/chrome/google-chrome-old-version.php
insert image description here
The download is complete.
3. Disable automatic update of Chrome browser:
Enter the "Services" panel from the "Start Menu".
Find the Google update service:
insert image description here
Right-click → Properties, change the startup type to "Disabled":
insert image description here
Chrome will no longer automatically update at this time:
insert image description here
Disable update pop-ups:
Right-click Google Chrome → Properties → Add after the target column: --disable-background-networkinginsert image description here
Click OK.

Three, chromedriver download configuration

1. Download the chromedriver corresponding to the Chrome browser
2. After decompression, copy chromedriver.exe to the Chrome and Python directories respectively
(1) Under the Chrome directory:
right-click the Google Chrome icon → open the location of the file:
insert image description here
(2) Under the Python directory :
① Find python location: Enter in cmd where python:
insert image description here

② Copy and paste the chromedriver into the Scripts directory of python:
insert image description here

3. Set environment variables:
Right-click "My Computer" → Properties → Advanced System Settings → Environment Variables,
edit the Path in "User Variables", addC:\Program Files (x86)\Google\Chrome\Application
insert image description here

4. Test

Open the python compiler and write the following code:

from selenium import webdriver
from time import sleep

driver = webdriver.Chrome()
driver.get("http://www.baidu.com")
sleep(2)
driver.quit()

Check the running results:

success!

Guess you like

Origin blog.csdn.net/jylsrnzb/article/details/131492090