问题
I have such code :
casper.thenOpen(url, function() {
this.echo('Opening at ' + width);
//give some time for the page to load
casper.waitFor(function check() {
return this.evaluate(function() {
return document.querySelectorAll('#browse-packshots').length > 0;
});
}, function then() {
//set the viewport to the desired height and width
this.viewport(width, height);
//Set up two vars, one for the fullpage save, one for the actual viewport save
var FPfilename = saveDir + '/fullpage-' + width + ".png",
ACfilename = saveDir + '/' + width + '-' + height + ".png";
//Capture selector captures the whole body
this.captureSelector(FPfilename, 'body');
//capture snaps a defined selection of the page
this.capture(ACfilename,{top: 0,left: 0,width: width, height: height});
this.echo('snapshot taken');
},function timeout() {
this.echo("Too long . No screenshot taken").exit();
},10000);
})
Casper version is 1.0.4 on Mac. When I want to use captureSelector I'm getting
[error] [phantom] Failed to save screenshot to fullpage-1440.png;
please check permissions...
With capture there is no problem. I event try with sudo but with no effect.
回答1:
I think I found answer . I change one stuff in code:
this.captureSelector(FPfilename, 'html');
Have not idea why it wasn't working.
来源:https://stackoverflow.com/questions/20070925/casperjs-and-failed-to-save-screenshot-with-captureselector