今日问题:解决最新Chrome和chromedriver版本对不上的问题

python 复制代码
from selenium import webdriver
#from .chrome.webdriver import WebDriver as Chrome
from selenium.webdriver.common.by import By
from time import sleep
driver = webdriver.Chrome()

driver.get("https://www.baidu.com/")
driver.maximize_window()#窗口最大化
sleep(1)
element = driver.find_element(by=By.ID,value="kw")
element.send_keys("selenium")
print(type(element))
driver.find_element(by=By.ID,value="su").click()

sleep(3)
driver.quit()

代码执行报错

The chromedriver version (114.0.5735.90) detected in PATH at C:\Users\jeffky\Desktop\selenium\webdriver\chromedriver.exe might not be compatible with the detected chrome version (119.0.6045.200); currently, chromedriver 119.0.6045.105 is recommended for 。。。

报错分析结果:Chrome和chromedriver版本对不上的问题

解决:

1.打开网站: ChromeDriver - WebDriver for Chrome - Downloads

2.若列表没有你的版本,点击:the Chrome for Testing availability dashboard

3.复制链接下载

4.将下载的chromedriver替换本地版本低的chromedriver

5.运行代码---成功

相关推荐
Csvn20 小时前
🌟 LangChain 30 天保姆级教程 · Day 13|OutputParser 进阶!让 AI 输出自动转为结构化对象,并支持自动重试!
python·langchain
cch891820 小时前
Python主流框架全解析
开发语言·python
海的透彻20 小时前
nginx启动进程对文件的权限掌控
运维·chrome·nginx
sg_knight20 小时前
设计模式实战:状态模式(State)
python·ui·设计模式·状态模式·state
好运的阿财20 小时前
process 工具与子agent管理机制详解
网络·人工智能·python·程序人生·ai编程
张張40821 小时前
(域格)环境搭建和编译
c语言·开发语言·python·ai
weixin_4235339921 小时前
【Windows11离线安装anaconda、python、vscode】
开发语言·vscode·python
Ricky111zzz21 小时前
leetcode学python记录1
python·算法·leetcode·职场和发展
小白学大数据21 小时前
Selenium+Python 爬虫:动态加载头条问答爬取
爬虫·python·selenium
Hui Baby21 小时前
springboot读取配置文件
后端·python·flask