前言:跟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-10-09:杨辉三角。给定一个非负整数 numRows,生成「杨辉三角」的前 numRows 行。在「杨辉三角」中,每个数是它左上方和右上方的数的和。力扣118。

    2021-10-09:杨辉三角.给定一个非负整数 numRows,生成「杨辉三角」的前 numRows 行.在「杨辉三角」中,每个数是它左上方和右上方的数的和.力扣118. 福大大 答案2021-10 ...

  2. WSGI实现支持多URL的WEB服务器

  3. Dapr在Java中的实践 之 环境准备

    Dapr简介 Dapr (Distributed Application Runtime)是一个可移植的.事件驱动的运行时,它使任何开发人员都可以轻松地构建运行在云和边缘上的弹性.无状态和有状态的应用 ...

  4. Anaconda 环境下 R 包 ggraph_1.0.2 安装小记

    由于微信不允许外部链接,你需要点击文章尾部左下角的 "阅读原文",才能访问文中链接. 记录一下今天在 Anaconda3 环境下 R==3.4.3 中安装 ggraph 的一些问题 ...

  5. JumpServer安装及应用

    jumpserver安装 安装所需软件包 [root@localhost ~]# yum -y update [root@localhost ~]# dnf install -y wget curl ...

  6. 天下苦 Spring 久矣,Solon v2.3.3 发布

    Solon 是什么框架? 一个,Java 新的生态型应用开发框架.它从零开始构建,有自己的标准规范与开放生态(全球第二级别的生态).与其他框架相比,它解决了两个重要的痛点:启动慢,费资源. 解决痛点? ...

  7. 【技术积累】Python中的NumPy库【二】

    NumPy库的主要类有哪些? NumPy库的主要类包括: ndarray:N维数组对象,是NumPy最重要的类之一.它是Python中数组的基本数据结构,可以进行高效的数学计算和数据处理操作. ufu ...

  8. 搭建私人GPT及域名配置

    前几天在掘金看到一个搭建私人ChatGPT的教程,看起来并不难. 我也有OpenAI的API Key,然后前阵子我看到我的账号余额还有很多,我的api key其实就一个机器人在用,没用多少. 还有,就 ...

  9. 企业battle宝典Q1 每一个身处于抑郁与困难的朋友必看!

    里面有看不懂的可以留言,我会解释!

  10. Python爬虫(二):写一个爬取壁纸网站图片的爬虫(图片下载,词频统计,思路)

    好家伙,写爬虫   代码: import requests import re import os from collections import Counter import xlwt # 创建Ex ...