0

I would like to upload a picture and it's working in local but failing on jenkins with the following code:

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

await this.uploadButton.sendKeys(absolutePath);

I get the this error message:

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

3 Answers3

0

did you try double quotes in your path e.g "../../yourimg.png" ? I think that you need to include in "" your path .

imamalis
  • 65
  • 5
0
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);

I have something like this in my project and it works fine. We're using Bamboo instead of Jenkins

Kuba Lubas
  • 81
  • 3
0

Seems like a problem with file detecting remotely (while on jenkins). You probably have to set up the file detection with the protractor browser.

I suggest you take a look at Remote File Upload Protractor test

Winify
  • 18
  • 1
  • 5
  • Many thanks. Refreshing typescipt and addig these 2 lines solved the problem: `import * as remote from 'selenium-webdriver/remote';` `browser.setFileDetector(new remote.FileDetector());` – lukszits Feb 25 '19 at 12:36