作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我拉取了 jenkins 容器,它在我本地主机的 8080 端口暴露了 jenkins。
我可以看到 Jenkins 运行良好。我已经安装了 pip我已经用 pip 安装了 selenium当我运行测试时出现错误:
+ 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 驱动程序?
最佳答案
一种简单的方法是基于官方镜像构建您的自定义 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 绑定(bind)的 Python3。如您所愿。
您可以使用我的镜像,也可以查看源代码并自行构建:
关于selenium - 如何在 jenkins 中安装 selenium chrome 驱动程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45190026/
我是一名优秀的程序员,十分优秀!