surya pratap
surya pratap

Reputation: 61

failed to save screenshot to a location in casperjs (windows7 64 bit)

When trying to capture a screenshot and save it in casperjs, it throws the following error

[error] [phantom] Failed to save screenshot to a local directory. please check permissions

Tried lot of ways like

I am using Windows 7 64 bit machine.

Already gone through this link here

Upvotes: 5

Views: 2163

Answers (6)

Henry
Henry

Reputation: 1424

Sometimes a file with the same name already exists, and is opened by a program (image viewer) so casperjs/phantomjs can't delete it before rewriting.

Upvotes: 0

GreeneCreations
GreeneCreations

Reputation: 1242

You can also get that error message if you haven't specified a file extension. There is no default image extension, so you have to specify:

// this won't work
this.captureSelector("./images/filename", "html");

// this WILL work
this.captureSelector("./images/filename.png", "html");

Upvotes: 0

Broza
Broza

Reputation: 1

I've had the same error running Casperjs on Windows. For me closing and reopen the command prompt makes the script work again.

Upvotes: 0

user3663707
user3663707

Reputation: 31

I've had this same issue. save name also can make this problem. i used to save file name as get.Title() some of site name didn't proper as file name

 var title = this.getTitle();
       this.echo(title);
        var filename = i + '_' + title + '.png';

--> var filename = i + '_.png';

Upvotes: 0

Mike Karlsven
Mike Karlsven

Reputation: 9

I've had this same issue recently and I solved it by allowing multiple ssl protocols using the following:

casperjs --ssl-protocol=any myscript.js

Upvotes: 0

yoav barnea
yoav barnea

Reputation: 5994

I had the same error. and from what i found , it's also possible getting this error when the screenshot retrieved from a url/link which has no response body (see also here)

So I solved that through something like that:

 ...

 if (this.exists("body")) {   // this refer to the casper object
     this.capture(myTrgFile);
}

please note that the request body and the tag body are two different things. I used the tag ("body") in my example only because it usually appears when requesting an html page. (the tag body is locate in the request body)

hope that helps...

Upvotes: 2

Related Questions