青龙面板运行selenium启动Chrome报错

Bug Description

在青龙面板运行selenium启动 Chrome 时,出现以下错误:

shell 复制代码
selenium.common.exceptions.WebDriverException: Message: chrome not reachable

这个错误信息表示 Chrome 浏览器无法被 Selenium 控制。

以下是python中对chrome的配置:

python 复制代码
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument('--single-process')
# 使用Selenium启动Chrome浏览器
driver = webdriver.Chrome(options=options)
print('Chrome启动成功')

Solution

后发现删除options.add_argument('--single-process')后,同时指定chromedriver对应路径,service = Service(executable_path='/usr/lib/chromium/chromedriver')后问题解决。我的青龙面板存在两个chromedriver,所以存在这个问题。

python 复制代码
service = Service(executable_path='/usr/lib/chromium/chromedriver')
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
# 使用Selenium启动Chrome浏览器
driver = webdriver.Chrome(options=options, service=service) 
print('Chrome启动成功')
相关推荐
青 春 记 忆1 天前
LeetCode 155. 最小栈|Python 解法详解
开发语言·python·leetcode
程序员三藏1 天前
Python+requests实现接口自动化测试
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·接口测试
一直走下去-明1 天前
简单的http抓包解包完整代码
开发语言·python
雷帝木木1 天前
数据湖与数据仓库:从理论到实践
人工智能·python·深度学习·机器学习
数字化转型分享点滴1 天前
机加工车间上线 SH‑AIOT 物联网会遇到哪些常见实施难点
python·物联网
0566461 天前
agent学习——流式响应与文本切分
网络·python·学习
OPEN-F1 天前
Python进阶教程:正则表达式进阶与文本处理
开发语言·python·正则表达式
新网企兴1 天前
2026年陕西做GEO推广,找新网企兴解决获客难题
python·搜索引擎
青 春 记 忆2 天前
LeetCode 142. 环形链表 II|Python 解法详解
python·leetcode·链表
for_ever_love__2 天前
python基础语法学习: 面向对象的三大特性
开发语言·python·学习