Casperjs and Failed to save screenshot with captureSelector

随声附和 提交于 2019-12-22 13:49:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!