我正在GitLab上运行一个简单的CI管道,用于使用webdriver_manager处理铬驱动程序二进制文件的Selenium脚本。
本部分通过:
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")这是管道之一:https://gitlab.com/mmonfared/test/-/jobs/2350697126
这是一个示例项目:https://gitlab.com/mmonfared/test
我还在webdriver_manager github上发表了一个问题,目前还没有答案:
https://github.com/SergeyPirogov/webdriver_manager/issues/363
发布于 2022-04-19 22:40:24
这个错误信息..。
WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/100.0.4896.60/chromedriver unexpectedly exited. Status code was: 127`...implies表示,您正在以根用户的身份执行测试。
深潜
根据
Chrome在启动时崩溃的一个常见原因是在
上以根用户(管理员)的身份运行Chrome。虽然可以通过在创建
--no-sandbox会话时传递WebDriver标志来解决此问题,但这种配置是不受支持的,并且非常不受欢迎。请将您的环境配置为运行Chrome作为常规用户。
解决方案
以非根用户的身份执行测试。
https://stackoverflow.com/questions/71923052
复制相似问题