前言:跟GPT交互,让其写一段代码,执行失败。经过排查验证,GPT写的代码没有问题,是本地环境问题。


执行报错:

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 109
Current browser version is 112.0.5615.49 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe

报错分析:

此版本的ChromeDriver 仅支持Chrome版本109。当前浏览器版本为112.0.5615.49 。根据报错得知本地的谷歌浏览器已经更新。

解决办法:

将与谷歌浏览器版本匹配的chromedriver.exe放到Python的安装目录下,也就是和python.exe同目录即可。


详细过程,如下:

1. 让cursor写一段python代码,如下:

from selenium import webdriver

# Create a new Chrome browser instance
browser = webdriver.Chrome() # Navigate to the Baidu homepage
browser.get('https://www.baidu.com/') # Wait for the page to load
browser.implicitly_wait(10) # Take a screenshot of the page and save it to a file
browser.save_screenshot('baidu_screenshot.png') # Close the browser
browser.quit()

2. 在pycharm运行报错,如下:

"D:\Program Files\python3\python.exe" "D:\Program Files\python3\Zyl\2023-04-11\demo11.py"
Traceback (most recent call last):
File "D:\Program Files\python3\Zyl\2023-04-11\demo11.py", line 4, in <module>
browser = webdriver.Chrome()
File "D:\Program Files\python3\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
super().__init__(
File "D:\Program Files\python3\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 106, in __init__
super().__init__(
File "D:\Program Files\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 288, in __init__
self.start_session(capabilities, browser_profile)
File "D:\Program Files\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 381, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "D:\Program Files\python3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 444, in execute
self.error_handler.check_response(response)
File "D:\Program Files\python3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 249, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 109
Current browser version is 112.0.5615.49 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe
Stacktrace:
Backtrace:
(No symbol) [0x005B6643]
(No symbol) [0x0054BE21]
(No symbol) [0x0044DA9D]
(No symbol) [0x00472911]
(No symbol) [0x0046D630]
(No symbol) [0x0046A899]
(No symbol) [0x004A6917]
(No symbol) [0x004A655C]
(No symbol) [0x0049FB76]
(No symbol) [0x004749C1]
(No symbol) [0x00475E5D]
GetHandleVerifier [0x0082A142+2497106]
GetHandleVerifier [0x008585D3+2686691]
GetHandleVerifier [0x0085BB9C+2700460]
GetHandleVerifier [0x00663B10+635936]
(No symbol) [0x00554A1F]
(No symbol) [0x0055A418]
(No symbol) [0x0055A505]
(No symbol) [0x0056508B]
BaseThreadInitThunk [0x76C37D49+25]
RtlInitializeExceptionChain [0x774CB74B+107]
RtlClearBits [0x774CB6CF+191] Process finished with exit code 1

3. 配置谷歌驱动

  谷歌驱动下载地址:http://chromedriver.storage.googleapis.com/index.html

  驱动版本须与浏览器版本一致。

  将下载好的浏览器驱动解压,将解压出的 exe 文件替换到Python的安装目录下,也就是和python.exe同目录即可。

4. 再次执行代码,执行成功。

"D:\Program Files\python3\python.exe" "D:\Program Files\python3\Zyl\2023-04-11\demo11.py" 

Process finished with exit code 0

selenium报错:This version of ChromeDriver only supports Chrome version 109 Current browser version is 112.0.5615.49...解决办法的更多相关文章

  1. UI自动化执行时报Parent suite setup failed: SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81报错的问题解决

    持续集成在执行UI时报错:Parent suite setup failed: SessionNotCreatedException: Message: session not created: Th ...

  2. asp.net报错“尝试读取或写入受保护的内存。这通常指示其他内存已损坏”的解决办法

    来源:http://ajxfxb.blog.163.com/blog/static/56675086201411634336878/ 作者是:没完没了的工作 asp.net报错“尝试读取或写入受保护的 ...

  3. win 2012 安装mysql 5.7.20 及报错 This application requires Visual Studio 2013 Redistributable. Please install the Redistributable then run this installer again 的解决办法

    本文地址:http://www.cnblogs.com/jying/p/7764147.html    转载请注明出处. 安装过程其实挺简单,基本上下一步下一步,可以参考我的另一篇mysql安装文章: ...

  4. Selenium chromeDriver启动时报错:session not created: This version of ChromeDriver only supports Chrome

    解决方案: 这是因为ChromeDriver与本地chrome浏览器的版本不一致导致 ChromeDriver下载地址:http://npm.taobao.org/mirrors/chromedriv ...

  5. 运行python代码报错UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 91: ordinal not in range(128)的解决办法

    1.通过搜集网上的资料,自己多次尝试,问题算是解决了,在代码中加上如下几句即可: import sys reload(sys) sys.setdefaultencoding('utf-8') 2.原因 ...

  6. vue引入fastclick设置输入框type="number"报错Failed to execute 'setSelectionRange' on 'HTMLInputElement': The input element's type ('number') does not support selection.的解决办法

    将输入框type设为text,通过正则验证输入的值

  7. 解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist

    解决centos7下 selenium报错--unknown error: DevToolsActivePort file doesn't exist 早上在linux下用selenium启动Chro ...

  8. selenium报错以及各解决方法

    1.driver.findElement(By.name("wd")).sendKeys("selenium"); 报错:The method sendKeys ...

  9. Selenium报错:StaleElementReferenceException

    一个学生在操作页面跳转时遇到一个Selenium报错, 如下图所示: StaleElementReferenceException: Message: stale element reference: ...

  10. selenium报错汇总

    selenium报错汇总 报错:[error] Could not connect to Selenium Server. Have you started the Selenium Server y ...

随机推荐

  1. 2021-12-03:石子游戏 IV。Alice 和 Bob 两个人轮流玩一个游戏,Alice 先手。 一开始,有 n 个石子堆在一起。每个人轮流操作,正在操作的玩家可以从石子堆里拿走 任意 非零 平

    2021-12-03:石子游戏 IV.Alice 和 Bob 两个人轮流玩一个游戏,Alice 先手. 一开始,有 n 个石子堆在一起.每个人轮流操作,正在操作的玩家可以从石子堆里拿走 任意 非零 平 ...

  2. HDU - 7125 Master of Shuangpin

    D. Master of Shuangpin time limit per test 1 second memory limit per test 256 megabytes input standa ...

  3. 【python基础】复杂数据类型-列表类型(增删改查)

    1.初识列表(list) 列表由一系列按特定顺序排列的数据元素组成.可以将任何类型数据元素加入列表中,其中的数据元素之间没有任何关系.鉴于列表通常包含多个数据元素,给列表指定一个表示复数的名称是个不错 ...

  4. Vue自定义指令-让你的业务开发更简单

    1.使用场景 在日常开发中,我们会将重复代码抽象为一个函数或者组件,然后在需要时调用或者引入.但是,对于某些功能,这种方法可能不够优雅或者不够灵活.例如,我们可能需要在DOM元素上添加一些自定义属性或 ...

  5. kafka的安装和基本操作

    基本概念 简介 Kafka 最初是由 LinkedIn 即领英公司基于 Scala 和 Java 语言开发的分布式消息发布-订阅系统,现已捐献给Apache 软件基金会.其具有高吞吐.低延迟的特性,许 ...

  6. C#与WPF中相关字符串操作

    字符串指定字符查找 例如:输入一个邮箱地址,如果正确则显示success否则显示error(正确的邮箱地址包含@,以.com结尾) //接受输入进来的字符串 string s=this.txtEmsi ...

  7. 20200411 联想Yoga 2 13升级大SSD

    20200411:下文的操作实际发生在2018年11月,当时完成了就写好了这篇文章,却忘了放上来,最近家里一个电脑的硬盘坏了,来翻箱底才找到,现在发上来. 原配置:Lonevo Yoga2 13,唯一 ...

  8. 【python基础】函数-初识函数

    函数是带名字的代码块,用于完成具体的工作,无需反复编写完成该工作的代码.之前我们接触过print函数,数据类型转换中的int函数.str函数,还有列表中的append函数.pop函数.remove函数 ...

  9. Vue-CoreVideoPlayer 视频播放器组件

    安装 cnpm install -S vue-core-video-player 快速使用 # 在main.js中 import VueCoreVideoPlayer from 'vue-core-v ...

  10. XTTS系列之四:迷迷糊糊的并行度

    项目测试组又反馈一个问题,XTTS执行全量备份速度慢,影响测试进度. 实际算了下,平均速度才150MB/s.. 这个速度在客户生产环境的确是不够看,首先询问是否开了并行,开了多少? 回复是说有开32个 ...