前言:跟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. 大米cms爆破后台及支付逻辑漏洞

    又找到个网站挖洞,我来康康. 大米手机是个什么鬼手机??看一下吧 这个支付页面好熟悉,可能存在支付逻辑漏洞,咱们用burp改个包看看. 先支付一个看看 把包里那个=1改成0试试~ 证实确实存在支付逻辑 ...

  2. 2020-10-21:go中channel的send流程是什么?

    福哥答案2020-10-21: ***[评论](https://user.qzone.qq.com/3182319461/blog/1603234689)

  3. 2021-01-31:Redis集群方案不可用的情况有哪些?

    福哥答案2021-01-31:[答案来自此链接:](https://www.zhihu.com/question/442112697)一个集群模式的官方推荐最小最佳实践方案是 6 个节点,3 个 Ma ...

  4. 2022-04-01:有n个人,m个任务,任务之间有依赖记录在int[][] depends里。 比如: depends[i] = [a, b],表示a任务依赖b任务的完成, 其中 0 <= a <

    2022-04-01:有n个人,m个任务,任务之间有依赖记录在int[][] depends里. 比如: depends[i] = [a, b],表示a任务依赖b任务的完成, 其中 0 <= a ...

  5. 一个.Net Core开发的开源动态壁纸软件

    推荐一个Github上Start超过10.8K的超火.好用.强大的.内置很多优美的动态壁纸软件. 项目简介 这是基于.Net Core+WPF开发的.开源的动态壁纸软件,壁纸设置支持任何文件形式,包括 ...

  6. C#设计模式19——装饰器模式的写法

    装饰器模式(Decorator Pattern)是一种结构型设计模式,它允许你动态地给一个对象添加一些额外的职责,而不需要修改这个对象的代码. What(什么) 装饰器模式是一种结构型设计模式,它允许 ...

  7. C++面试八股文:static和const的关键字有哪些用法?

    某日二师兄参加XXX科技公司的C++工程师开发岗位第7面: 面试官:C++中,static和const的关键字有哪些用法? 二师兄:satic关键字主要用在以下三个方面:1.用在全局作用域,修饰的变量 ...

  8. 前端自定义弹框组件、自定义弹框内容alertView popup组件

    快速实现前端自定义弹框.自定义弹框内容alertView popup组件, 请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=12491 效果图 ...

  9. 【LeetCode摩尔投票】有趣的简单题:数组中出现次数超过一半的数字

    数组中出现次数超过一半的数字 https://leetcode.cn/problems/shu-zu-zhong-chu-xian-ci-shu-chao-guo-yi-ban-de-shu-zi-l ...

  10. 深入浅出synchronized的原理与源码

    深入浅出synchronized的原理与源码 1.java对象头关于锁的标识 1.对象头 // 32 bits: // -------- // hash:25 ------------>| ag ...