0

I'm a newbie of CasperJS. I'm trying to download a file after clicking on a button.

I've successfully intercepted the url using

casper.on('resource.received', function(resource) {
    if (resource.stage !== "end") {
        return;
    }
    if (resource.url.indexOf('Xml') > -1) {
        this.echo(JSON.stringify(resource));
    }
});

But I cannot download the file at all.
Checking with Charles I found out that two ajax calls are performed: the first is the one I intercept, and returns a xml with a CDATA. In this CDATA there is JS code with the url used from the page to start the download request.

It's possible to intercept or emulate this behavior in CasperJS?

Best, Marco

Marco Fedele
  • 2,090
  • 2
  • 25
  • 45
  • Possible duplicate of [Grab the resource contents in CasperJS or PhantomJS](http://stackoverflow.com/questions/11531448/grab-the-resource-contents-in-casperjs-or-phantomjs) – Artjom B. May 13 '16 at 19:28
  • Or my answer here: http://stackoverflow.com/a/24561614/1816580 – Artjom B. May 13 '16 at 19:28

0 Answers0