类应用程序(对象):
def __init__(self):
self.driver = webdriver.Chrome(executable_path='C:/Users/Admin/365_python_test/chromedriver.exe')
这是我对webdriver的初始化。它在我的机器上运行良好,但是当我将代码推送到gitlab CI时,出现错误“ chromedriver.exe”可执行文件,该文件必须位于PATH中。据我了解,我必须在“脚本之前”部分的.gitlab-ci.yml中设置Path,但是我不知道该怎么做。我尝试了在这里找到的其他脚本,但是它不起作用。我也尝试过:
self.driver = webdriver.Chrome(ChromeDriverManager().install())
在CI上也不起作用:
venv/lib/python3.7/site-
packages/selenium/webdriver/common/service.py:111: WebDriverException
---------------------------- Captured stdout setup ---------------------
--------
Checking for linux64 chromedriver:2.46 in cache
There is no cached driver. Downloading new one...
Trying to download new driver from
http://chromedriver.storage.googleapis.com/2.46/chromedriver_linux64.zip
Unpack archive /root/.wdm/chromedriver/2.46/linux64/chromedriver.zip
=========================== 1 error in 1.30 seconds
============================
ERROR: Job failed: exit code 1
请帮助!