gpt4 book ai didi

selenium - 如何在 jenkins 中安装 selenium chrome 驱动程序?

转载 作者:行者123 更新时间:2023-12-02 18:04:12 30 4
gpt4 key购买 nike

我拉取了 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。如您所愿。

您可以使用我的镜像,也可以查看源代码并自行构建:

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

关于selenium - 如何在 jenkins 中安装 selenium chrome 驱动程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45190026/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com