Casperjs,无法使用captureSelector保存屏幕截图 [英] Casperjs and Failed to save screenshot with captureSelector

查看:207
本文介绍了Casperjs,无法使用captureSelector保存屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的代码:

  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版本在Mac上为1.0.4.当我想使用captureSelector时

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

有了捕获就没有问题.我尝试使用sudo尝试,但没有效果.

With capture there is no problem. I event try with sudo but with no effect.

推荐答案

我认为我找到了答案.我在代码中更改了一件东西:

I think I found answer . I change one stuff in code:

this.captureSelector(FPfilename, 'html');

不知道为什么它不起作用.

Have not idea why it wasn't working.

这篇关于Casperjs,无法使用captureSelector保存屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆