【问题标题】:How to copy geckodriver to path /usr/local/bin/ in Gitlab pipeline?如何将 geckodriver 复制到 Gitlab 管道中的路径 /usr/local/bin/?
【发布时间】:2021-03-12 08:42:49
【问题描述】:

我正在使用此命令将 geckodriver 复制到路径但我仍然遇到问题

- wget https://github.com/mozilla/geckodriver/releases/download/v0.29.0/geckodriver-v0.29.0-linux64.tar.gz
- echo "geckodriver downloaded successfully"
- tar -xvzf geckodriver*
- chmod +x geckodriver
- export PATH=$PATH:/usr/local/bin

ERROR : 

==============================================================================
Firefox                                                                       
==============================================================================

WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
------------------------------------------------------------------------------

【问题讨论】:

    标签: linux selenium gitlab-ci pipeline geckodriver


    【解决方案1】:

    安装webdriver-manager包并添加到你的requirements.txt文件中:

    pip install webdriver-manager
    

    并像这样使用:

    from selenium import webdriver
    from webdriver_manager.firefox import GeckoDriverManager
    
    driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
    

    有了那个包,你就不用再担心 geckodriver了

    【讨论】:

    • 你的意思是脚本需要在requirements.txt中添加?
    • @RueL 不,编写我写的脚本添加而不是你的驱动程序初始化并制作 pip freeze > requirements.txt,gitlab 使用新的 webdriver_manager 安装所有新的依赖项。你的代码在本地工作吗?
    • 抱歉回复晚了。我现在能够解决我的问题。感谢你们对我的帮助。 :) 竖起大拇指!!!!
    • @RueL,请确认解决问题,我将获得奖励和声望,干杯!
    猜你喜欢
    • 2013-04-22
    • 2019-04-29
    • 2011-06-03
    • 2021-02-10
    • 1970-01-01
    • 1970-01-01
    • 2014-08-05
    • 2021-03-25
    • 2011-07-18
    相关资源
    最近更新 更多