selenium - 如何在 Jenkins 工作中使用 Selenium WebDriver?
问题描述
我编写了一些使用 Selenium 和 Chrome 版本 76.0.3809.68 的 WebDriver 的 JUnit 测试。当我使用 mvn clean install 执行 maven 模块时,一切正常,但是当我尝试在 Jenkins 作业中运行它时,出现以下错误:
The driver is not executable: /jenkins/workspace/webUI.ITests/target/test-classes/calculator/chromedriverunix
现在我已经尝试对 chromedriver.exe 文件做同样的事情,但我得到了同样的错误。这两个驱动程序都来自 selenium 网站,应该是正确的。这是我设置驱动程序的代码:
if (System.getenv("ON_JENKINS") == null) {
URL res = this.getClass().getResource("chromedriverunix");
File file = Paths.get(res.toURI()).toFile();
return file.getAbsolutePath();
} else {
URL res = this.getClass().getResource("chromedriver.exe");
File file = Paths.get(res.toURI()).toFile();
return file.getAbsolutePath();
}
这两个文件肯定都存在于构建中。先感谢您!
解决方案
这似乎与 Unix 上的权限有关。您可以通过执行chmod 777 chromedriverunix
或chmod +x chromedriverunix
在chromedriver所在的文件夹中更改它。
推荐阅读
- c# - 使用 c# 更改默认纸张大小不起作用
- azure - 没有密钥的 JSON 数组 - Azure 逻辑应用
- elasticsearch - 如何在 kubernetes 上创建没有此错误 elasticsearch 的 pod
- npm - 在安装后脚本中运行“下一个构建”后出现“需要适当的加载器”错误
- javascript - 为什么hammer.js 刷卡不适用于iPhone
- python - 我可以在 kubernetes python 客户端中使用正则表达式作为作业名称吗?
- angular - 如何使用 Angular 服务提供第三方 API,如传单或谷歌地图?
- wso2 - 导出 WSO2 API
- ios - Nativescript 是否使用 UIWebView API
- forms - 如何从另一个 dart 文件中调用有状态小部件(有表单)方法?- Flutter