今日问题:解决最新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 小时前
Unsafe方法学习
java·python·学习
老师好,我是刘同学4 小时前
Python执行命令并保存输出到文件
python
啵啵鱼爱吃小猫咪6 小时前
机械臂阻抗控制github项目-mujoco仿真
开发语言·人工智能·python·机器人
MaximusCoder6 小时前
等保测评命令——Centos Linux
linux·运维·经验分享·python·安全·centos
yunyun321236 小时前
用Python生成艺术:分形与算法绘图
jvm·数据库·python
m0_662577976 小时前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python
songyuc7 小时前
【PyTorch】感觉`CrossEntropyLoss`和`BCELoss`很类似,为什么它们接收labels的shape常常不一样呢?
人工智能·pytorch·python
ℳ๓₯㎕.空城旧梦7 小时前
Python单元测试(unittest)实战指南
jvm·数据库·python
浩子智控8 小时前
python程序打包的文件地址处理
开发语言·python·pyqt
Jackey_Song_Odd8 小时前
Part 1:Python语言核心 - 序列与容器
开发语言·windows·python