今日问题:解决最新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.运行代码---成功

相关推荐
隐于花海,等待花开1 分钟前
16.Python 常用第三方库概览 深度解析
python
我材不敲代码2 分钟前
Python 函数核心:位置参数与关键字参数详解
java·前端·python
风落无尘4 分钟前
第十一章《对齐与安全》 完整学习资料
python·安全·机器学习
Kratzdisteln6 分钟前
【无标题】
前端·python
hakesashou11 分钟前
python文件操作需要导入模块吗
python
wuxinyan12313 分钟前
工业级大模型学习之路029:解决双智能体调用数据库报错问题
数据库·人工智能·python·学习·智能体
SunnyDays101120 分钟前
Python操作Excel批注:从基础添加到高级自定义的完整指南
开发语言·python·excel
独隅29 分钟前
PyTorch自动微分模块:从原理到实战一
人工智能·pytorch·python
汤米粥1 小时前
python学习——核心语法三
java·python·学习
七老板的blog2 小时前
从持久化任务到多 Agent 协作
python·学习·ai