Chromedriver.exe installation and configuration under Windows system

Chromedriver.exe installation and configuration under Windows system

When using selenium tools for web automation testing, you must first install browser drivers, usually Google Chrome and Firefox browsers are more commonly used.

1. Browser driver download address

1. Browser driver official website : http://chromedriver.storage.googleapis.com/index.html
2. Taobao mirror website (recommended) : http://npm.taobao.org/mirrors/chromedriver/

2. Configuration process

First of all, you need to check the version of Google Chrome before opening the website. The driver must be consistent with the browser version, otherwise it will not work.

insert image description here
insert image description here

Secondly , open the driver website and find the driver download that matches the version number

insert image description here

Finally, place the downloaded driver in the following two places:
(1) Copy the exe file to D:\Chrome\Application under the browser installation directory.

insert image description here

(2) For the Anaconda environment, copy the exe file to D:\Anaconda\Scripts

insert image description here

For the python environment, copy the exe file to the same level as the python .exe file

insert image description here

(3) Configure environment variables
Right-click the mouse and click Properties→Advanced System Settings→Environment Variables→System Variables→Find Path→New Copy the installation path of D:\Anaconda\Scripts or python to it.
New to install the address of Google Chrome to the path is also copied to it.

insert image description here

3. Test

import time
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.baidu.com')
time.sleep(1)

insert image description here
If this is being controlled by automated testing software, it means that the configuration has been successful.
If you still can't find Google's .exe driver file, you can specify the path yourself.

import time
from selenium import webdriver
driver_path = r'D:\Chrome\Application\chromedriver.exe'
driver = webdriver.Chrome(executable_path=driver_path)
driver.get('http://www.baidu.com')
time.sleep(1)

Guess you like

Origin blog.csdn.net/weixin_57038791/article/details/130631803