无法在Jenkins管道中启动Firefox WebDriver

时间:2019-06-20 06:12:29

标签: selenium docker jenkins firefox

我正在尝试使用Selenium的Docker映像在Jenkins管道中运行自动化测试。我已经安装了Chrome浏览器,但没有Firefox。

这是最小的管道脚本:

node {
    docker.image('selenium/standalone-firefox:3.141.59-radium').inside('-u root:root -e START_XVFB=false') {
        sh '''
            curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py
            pip install selenium
            python -c 'from selenium import webdriver; options = webdriver.FirefoxOptions(); options.set_headless(); wd = webdriver.Firefox(options=options)'
        '''
    }
}

为清楚起见,这是Python脚本:

from selenium import webdriver

options = webdriver.FirefoxOptions()
options.set_headless()
wd = webdriver.Firefox(options=options)

返回的错误是

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
    keep_alive=True)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

我期望使用无头模式来解决此问题,如在其他地方建议的那样。相同的Shell脚本也可以在我的机器上使用。

0 个答案:

没有答案