1. 找到本机的Chrome版本
2. http://chromedriver.storage.googleapis.com/index.html
搜索你电脑对应版本,没有找临近版本
3. 点击下载,解压缩 chromedriver.exe
4. 放在三个地方
C:\Program Files (x86)\Google\Chrome\Application
本机安装python的地方
pycharm创建虚拟环境的地方
code
from selenium import webdriver
from selenium.webdriver.common.by import By
webdriver.Chrome(executable_path="执行环境中/chromedriver.exe")
driver.get("https://www.baidu.com/")
ele1 = self.driver.find_elements(By.XPATH, ‘/html/body/div[1]/div[1]/div[3]/a[1]’)
print(ele1[0].text)
driver.close()