2

Issue : File getting downloaded in one of e2e tescases is not getting saved to given folder in jenkins workspace

Setup : jenkins + protractor + cucumber + headless browser (chrome).

seetings :

capabilities: 
{
    'browserName': 'chrome',
    chromeOptions: {
     args: ['--headless','window-size=1366,768'],
        prefs: {
            'download': {
                'prompt_for_download': false,
                'directory_upgrade': true,
             'default_directory': process.cwd()+'/Commons/downloads/'
            }
        }
    }
},

Code :

var workbook = XLSX.readFile(process.cwd()+'/Commons/downloads/test.xls');

whats happening : Same setup is working fine on my system : File gets downloaded to respective project folder and i am able to read it .

jenkins throws

"error_message": "Error: ENOENT: no such file or directory, open '/opt/jenkins_build/workspace/Projects/Project123/e2e-Test/Commons/downloads/test.xls'\n    at Error (native)\n    at Object.fs.openSync .

Tried :

  1. Replacing process.cwd() with process.env.WORKSPACE.

  2. creating a file using above paths .

    var fd = fs.openSync(process.env.WORKSPACE+'/Commons/downloads/test1.txt', 'w');

It successfully creates a file at desired workscope folder . This shows that path is correct and accesscible i think.

Can it be a issue that jenkins not allowing that downloaded file due to access /security related policies ? .

krishan
  • 131
  • 1
  • 4
  • 14
  • have you tried by adding relative path instead of process.cwd()? – Yash Jagdale Feb 23 '18 at 08:20
  • I have tried with using "'/opt/jenkins_build/workspace/Projects/Project123/e2e-Test/Commons/downloads/test.xls" and process.env.WORKSPACE + "/Commons/downloads". Downloaded file doesn't get saved at location given in chrme option. – krishan Feb 23 '18 at 10:01
  • Possible duplicate of [Protractor file download test fails when headless chrome](https://stackoverflow.com/questions/48831273/protractor-file-download-test-fails-when-headless-chrome) – Barney Feb 23 '18 at 14:23
  • Where is the code that actually downloads. Potentially it is an async method and you have not downloaded it yet? – cnishina Feb 24 '18 at 16:38

0 Answers0