Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

  • saving it to other locations like public directory
  • changing the permissions of the local directory.
  • running the process as an administrator.

I am using Windows 7 64 bit machine.

Already gone through this link here

like image 277
surya pratap Avatar asked Nov 02 '22 09:11

surya pratap


1 Answers

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...

like image 112
yoav barnea Avatar answered Nov 16 '22 12:11

yoav barnea