青龙面板运行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启动成功')
相关推荐
程序小武30 分钟前
python编辑器如何选择?
后端·python
一叶知秋121138 分钟前
UV管理python项目
python
AndrewHZ44 分钟前
【图像处理入门】2. Python中OpenCV与Matplotlib的图像操作指南
图像处理·python·opencv·计算机视觉·matplotlib·图像操作
golitter.1 小时前
langchain学习 01
python·学习·langchain
一叶知秋12112 小时前
LangChain Prompts模块
python
量化金策2 小时前
截面动量策略思路
python
心软且酷丶3 小时前
leetcode:7. 整数反转(python3解法,数学相关算法题)
python·算法·leetcode
HAPPY酷3 小时前
selenium基础
selenium·测试工具
逾非时3 小时前
python:selenium爬取网站信息
开发语言·python·selenium
天才测试猿3 小时前
Selenium操作指南(全)
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例