'Invalid Filename- Download file

it('Empty download folder  - Sponsor', function () {
    applicationHelper.emptyFolder(dirPath);
    rimraf(dirPath + '*', function () {
        console.log('done');
    });
});
it('Download draft ct - Sponsor', function () {
    clinicalTrialsPage.downloadCt();
    pagesNavigation.navigateToByName('Applications');
    clinicalTrialsPage.selectDownloadOptionsforPartI();
    expect(topBanner.getMessageInToast()).toContain('Successfully Downloaded');
    browser.sleep(10000);
});
it('Check contents of zip', function () {
  let downloadedZip = glob.sync(dirPath + ctNumber + '*.zip');
    var zipFile = fs.readdirSync(dirPath);
    console.log(zipFile);
    zip = new admZip(dirPath + zipFile[0]);
    zip.getEntries().forEach(function (entry) {
        console.log(entry.entryName);
        zipEntry.push(entry.entryName);
    });
    zip.extractAllTo(dirPath + "zip/", false);
    expect(fs.existsSync(downloadedZip[0])).toBeTruthy();
});

I want to check that the downloaded file exists (which it does) but the script keeps failing, with the error invalid filename. The console.log(zipFile) gives a proper result. I use ChromeDriver for Selenium Protractor and the config.js is properly set up (capabilities,prefs etc) Any ideas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source