【问题标题】:Uploading a file in protractor on Jenkins在 Jenkins 的量角器中上传文件
【发布时间】:2019-02-25 01:51:24
【问题描述】:

我想上传一张图片,它在本地工作,但在 jenkins 上失败,代码如下:

const fileToUpload = await '../../files/test-automation-660x330.png';
const absolutePath = await path.resolve(__dirname, fileToUpload);

await this.uploadButton.sendKeys(absolutePath);

我收到此错误消息:

WebDriverError: invalid argument: File not found : /opt/jenkins_root/workspace/project-name-e2e/e2e/files/test-automation-660x330.png

【问题讨论】:

  • 你能仔细检查一下路径吗? files 目录是否存在?
  • 是的,因为它在本地工作

标签: jenkins file-upload protractor


【解决方案1】:

似乎是远程文件检测的问题(在詹金斯上)。您可能必须使用量角器浏览器设置文件检测。

建议你看看Remote File Upload Protractor test

【讨论】:

  • 非常感谢。刷新 typecipt 和 addig 这两行解决了问题:import * as remote from 'selenium-webdriver/remote';browser.setFileDetector(new remote.FileDetector());
【解决方案2】:

您是否尝试在路径中使用双引号,例如 "../../yourimg.png" ? 我认为你需要包含在 "" 你的路径中。

【讨论】:

  • like const fileToUpload = await '"../../files/test-automation-660x330.png"';?
  • 那不行。 :\ 这样两个路径将链接,但不与上层文件夹。
【解决方案3】:
const path = require('path');
const fileToUpload = path.resolve('./e2e/files-to-upload/testFile1.txt');
const fileButton= element(by.css('input[data-id=addDownloadableFileButton]'));

await addDownloadableFileButton.s`enter code here`endKeys(fileToUpload);

我的项目中有这样的东西,它工作正常。我们使用 Bamboo 而不是 Jenkins

【讨论】:

  • 我试过了,但我得到了同样的错误。也许问题就在詹金斯附近。
猜你喜欢
  • 1970-01-01
  • 2023-04-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-23
  • 2015-07-26
  • 1970-01-01
相关资源
最近更新 更多