1

The file download is triggered by clicking on a button. The button has an onclick attribute which initiates the file download.

Since I don't have the file url direclty. I cant use the request module to request the file as described in Download a file using Nightmare

Jeril Sebastian
  • 793
  • 7
  • 10

1 Answers1

0

You can try using nightmare-download-managerand do something like this:

nightmare.on('download', function(state, downloadItem) {
    if(state == 'started') {
        nightmare.emit('download', 'yourfilename.txt', downloadItem);
    } else if(state == 'completed') {
        console.log('Donwload completed');
    } else if(state == 'interrupted') {
        endNightmare();
    } else if(state == 'cancelled') {
        endNightmare();
    }
});

nightmare
.downloadManager()
.goto(url)
.click('#javascriptDownloadBtn')
.waitDownloadsComplete()
.then(function() {
    return nightmare.end();
})
Seb
  • 983
  • 1
  • 11
  • 26