如何在詹金斯中安装硒铬驱动程序?



我已经拉了 jenkins 容器,它在我的本地主机的端口 8080 处公开了 jenkins。

我可以看到詹金斯运行良好。 我已经安装了点子 我已经安装了带点的硒 当我运行测试时,出现错误:

+ python /var/jenkins_home/workspace/My_Job/slenium_login.py
12:02:06 Traceback (most recent call last):
12:02:06   File "/var/jenkins_home/workspace/My_Job/slenium_login.py", line 6, in <module>
12:02:06     driver = webdriver.Chrome(cd)
12:02:06   File "/var/jenkins_home/shiningpanda/jobs/5db0e2cb/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 62, in __init__
12:02:06     self.service.start()
12:02:06   File "/var/jenkins_home/shiningpanda/jobs/5db0e2cb/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 81, in start
12:02:06     os.path.basename(self.path), self.start_error_message)
12:02:06 selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

如何在我的 jenkins 环境中安装硒铬驱动程序?

一个简单的方法是基于官方镜像构建自定义 Jenkins docker 镜像。

结构将是这样的:

# Dockerfile
FROM jenkins
# Set user root to allow us to install the rest of what's needed
USER root
# <install your stuff here>
# Go back to non-sudo user
USER jenkins

我已经推送了一个图像docker pull elgalu/jenkins安装了Chrome,chromedriver和带有Selenium绑定的Python3。如你所愿。

您可以使用我的映像,也可以检查源代码并自己构建它:

https://github.com/elgalu/jenkins-chrome

相关内容

  • 没有找到相关文章

最新更新