青龙面板运行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启动成功')
相关推荐
presenttttt3 分钟前
用Python和OpenCV从零搭建一个完整的双目视觉系统(四)
开发语言·python·opencv·计算机视觉
木头左2 小时前
逻辑回归的Python实现与优化
python·算法·逻辑回归
quant_19863 小时前
R语言如何接入实时行情接口
开发语言·经验分享·笔记·python·websocket·金融·r语言
程序员的世界你不懂8 小时前
基于Java+Maven+Testng+Selenium+Log4j+Allure+Jenkins搭建一个WebUI自动化框架(2)对框架加入业务逻辑层
java·selenium·maven
失败又激情的man8 小时前
python之requests库解析
开发语言·爬虫·python
打酱油的;9 小时前
爬虫-request处理get
爬虫·python·django
程序员的世界你不懂10 小时前
基于Java+Maven+Testng+Selenium+Log4j+Allure+Jenkins搭建一个WebUI自动化框架(4)集成Allure报表
java·selenium·maven
用什么都重名11 小时前
MinerU:高效智能PDF文档解析工具完全指南
人工智能·python·pdf·mineru·makedown
倔强青铜三11 小时前
苦练Python第4天:Python变量与数据类型入门
前端·后端·python
这我可不懂11 小时前
Python 项目快速部署到 Linux 服务器基础教程
linux·服务器·python