簡體   English   中英

capture()方法在casperjs中工作不正確

[英]capture() method works incorrect in casperjs

casperjs捕獲窗口的一部分。 當我在casperj中測試時制作屏幕截圖時,就會發生這種情況。 我用

this.capture('google.png', {
    top: 0,
    left: 0,
    width: 1280,
    height: 960
});

我也嘗試使用

this.capture('google.png');

this.captureSelector('weather.png', '#body');

如何制作整個窗口(文檔)的屏幕截圖?

這對我有用,請嘗試設置viewport

var casper = require('casper').create ({
  waitTimeout: 15000,
  stepTimeout: 15000,
  verbose: true,
  viewportSize: {
    width: 1280,
    height: 960
  },
  pageSettings: {
    "userAgent": 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.10 (KHTML, like Gecko) Chrome/23.0.1262.0 Safari/537.10',
    "webSecurityEnabled": false,
    "ignoreSslErrors": true
  },
  onWaitTimeout: function() {
      // casper.capture('./out/wait-timeout:_' + TimeTidy() + '.png');
      // throw new Error stuff;
  },
  onStepTimeout: function() {
      // casper.capture('./out/step-timeout' + TimeTidy() + '.png');
      // throw new Error stuff;
  }
});

然后使用:

casper.capture('google.png');
// or if within casper block:
// this.capture('google.png');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM