casperjs捕获窗口的一部分。当我在casperj中测试时制作屏幕截图时会发生这种情况。我用
this.capture('google.png', {
top: 0,
left: 0,
width: 1280,
height: 960
});
我也尝试过使用
this.capture('google.png');
和
this.captureSelector('weather.png', '#body');
如何制作整个窗口(文档)的屏幕截图?
答案 0 :(得分:1)
这对我有用,请尝试设置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');