In a normal browser, if i click the link, the browser will open a dialog to save/open the file.
How do i automate this thing using casperjs. Below is the html code
<li>
<a id="rmdExport" href="#">Export markdown file</a>
</li>
after clicking on it, the browser window opens i tried with the following code but didn't worked
casper.then(function(){
functions.open_advanceddiv(casper);
casper.setFilter("page.prompt", function (msg, currentValue) {
if (msg === "You have choosen to open:") {
return true;
}
});
this.click("#rmdExport");
});
casper.on('resource.received', function(resource) {
if (resource.stage !== "end") {
console.log("resource.stage !== 'end'");
return;
}
if (resource.url.indexOf(Notebook+'.Rmd') > -1) {
console.log("Downloading md file");
this.download(resource.url, file+'.md');
}
});
casper.then(function (){
Notebook = this.fetchText(".jqtree-selected > div:nth-child(1) > span:nth-child(1)");
this.page.onFileDownload = function(status){console.log('onFileDownload(' + status + ')');
//SYSTEM WILL DETECT THE DOWNLOAD, BUT YOU WILL HAVE TO NAME THE FILE BY YOURSLEF!!
return Notebook+".md"; };
});
I gone through these links How i can save/download link with blob: ?, casperjs download csv file, downloading a file that comes as an attachment in a POST request response in PhantomJs
I know its duplicate question of all these. But i am helpless please help me with this