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

相关推荐
小邓的技术笔记几秒前
Python 入门:从“其他语言”到 Pythonic 思维的完整迁移手册
开发语言·python
北冥有羽Victoria1 分钟前
Django 实战:SQLite 转 MySQL 与 Bootstrap 集成
大数据·服务器·python·django·编辑器
忘忧记1 分钟前
Pytest + Requests + YAML 数据驱动+日志模块
网络·python·pytest
AI自动化工坊3 分钟前
微软Agent Framework实战指南:统一Python和.NET的AI开发体验
人工智能·python·microsoft·.net·agent
林姜泽樾5 分钟前
Python爬虫基础第一章,JSON
爬虫·python·网络爬虫
zzwq.13 分钟前
深入理解Python闭包与装饰器:从入门到进阶
开发语言·python
网易独家音乐人Mike Zhou13 分钟前
【Python】TXT、BIN文件的十六进制相互转换小程序
python·单片机·mcu·小程序·嵌入式·ti毫米波雷达
long_songs19 分钟前
Python编程第02课:Windows/Mac/Linux环境安装配置详解
windows·python·macos
别抢我的锅包肉26 分钟前
【Python】PySpark 核心实操入门指南
python
cyhysr27 分钟前
Python读取ppt文本转存txt
python·powerpoint