WebDriverexception(状态代码127)运行硒+ gitlab-ci机器上的webdriver_manager(Linux)
我在GitLab上运行了一条简单的CI管道,用于无头selenium脚本 +使用webdriver_manager
来处理Chrome驱动程序二进制。
该部分通过:
Get LATEST chromedriver version for None google-chrome
There is no [linux64] chromedriver for browser None in cache
Trying to download new driver from https://chromedriver.storage.googleapis.com/100.0.4896.60/chromedriver_linux64.zip
Driver has been saved in cache [/root/.wdm/drivers/chromedriver/linux64/100.0.4896.60]
但是在那之后,我会遇到此错误:
WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/100.0.4896.60/chromedriver unexpectedly exited. Status code was: 127`
问题是什么?似乎WebDriver_Manager在CI中运行有问题。
这是一个简单的复制脚本:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
service = Service(executable_path=ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options)
driver.get("http://google.com")
driver.find_element('name', 'q').send_keys("Wikipedia")
这是管道之一: htttps://gitlab.com/mmonfared/mmonfared/test/test/-/jobs/jobs/jobs/jobs/jobs/23506977126
这是一个示例项目: https://gitlab.com/mmonfared/test/test
我也在webriver_manager github github repo中开了一个问题, no answers yet:
https://github.com/SergeyPirogov/webdriver_manager/issues/363
I'm running a simple CI pipeline on GitLab for a Selenium script headlessly + using webdriver_manager
to handle chrome driver binary.
This part is passed:
Get LATEST chromedriver version for None google-chrome
There is no [linux64] chromedriver for browser None in cache
Trying to download new driver from https://chromedriver.storage.googleapis.com/100.0.4896.60/chromedriver_linux64.zip
Driver has been saved in cache [/root/.wdm/drivers/chromedriver/linux64/100.0.4896.60]
But after that I'm getting this error:
WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/100.0.4896.60/chromedriver unexpectedly exited. Status code was: 127`
What is the problem? Seems like webdriver_manager has a problem by running in CI.
Here is a simple script for reproduce:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
service = Service(executable_path=ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options)
driver.get("http://google.com")
driver.find_element('name', 'q').send_keys("Wikipedia")
This is one of the pipelines:
https://gitlab.com/mmonfared/test/-/jobs/2350697126
This is a sample project:
https://gitlab.com/mmonfared/test
I've also opened an issue in webdriver_manager github repo, no answers yet:
https://github.com/SergeyPirogov/webdriver_manager/issues/363
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此错误消息...
...意味着您正在执行测试作为 root 用户。
深度潜水
按不会立即启动或崩溃
解决方案
将测试执行为 non-root 用户。
This error message...
...implies that you are executing your tests as the root user.
Deep Dive
As per Chrome doesn't start or crashes immediately
Solution
Execute your tests as a non-root user.