我正在尝试使用casperjs访问paypal网页(并登录),我想截取页面的截图,看看它是否正常工作,但屏幕截图是空的,我收到警告:
[warning] [phantom] Loading resource failed with status=fail: https://www.paypal.com/
这是我的代码:
var casper = require('casper').create({
verbose: true,
logLevel: 'debug',
viewportSize: {
width: 1920,
height: 1440
}
});
var options = casper.cli.options;
if(options['url'] == null) {
casper.echo('No URL found');
casper.exit();
}
if(options['userAgent'] == null ){
casper.userAgent(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36'
);
} else {
casper.userAgent(options['userAgent']);
}
casper.start(options['url'], function(){
this.capture("screenshots/casper_start.png");
});
casper.waitForSelector('#btnLogin', function(){
this.fill('form name=["login"]',{
'#email': 'xxxxxx',
'#password': 'xxxxxx'
},true)
}, function(){
this.capture("screenshots/id_choose_timeout.png");
});
casper.wait(2000,function(){
this.capture("screenshots/wait2000.png");
});
casper.run();
这是我正在运行的命令:
casperjs --ssl-protocol=any paypal.js --url=https://www.paypal.com/signin
我也尝试过使用Google的SAME代码,并且工作正常。