我已拉出jenkins容器,在我的localhost中将端口8080暴露给jenkins。
我可以看到詹金斯运行良好。 我已经安装了pip 我用pip安装了硒 当我运行测试时,我得到一个错误:
+ 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环境中安装selenium chrome驱动程序?
答案 0 :(得分:1)
一种简单的方法是根据官方版本构建自定义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
我用已安装的Chrome,chromedriver和带有Selenium绑定的Python3推送了一张图片docker pull elgalu/jenkins
。按照你的要求。
您可以使用我的图片或查看源代码并自行构建: