這個工作對我來說,可以嘗試設置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');