不确定我在这里做错了什么......
我的代码:
var casper = require('casper').create({
verbose: true,
stepTimeout: 10000,
onError: function() {
this.captureSelector('error.png', 'html');
},
logLevel: "debug"
});
casper.start();
casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)');
casper.setHttpAuth('user', 'pass');
casper.thenOpen('https://www.google.com');
casper.then(function() {
this.echo(this.getCurrentUrl());
currentPage = this.getTitle();
this.captureSelector(currentPage + '.png', 'html');
});
casper.run();
我的错误:
$ casperjs test.js
[info] [phantom] Starting...
FAIL TypeError: 'undefined' is not a function (evaluating 'casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)')')
# type: uncaughtError
# error: "TypeError: 'undefined' is not a function (evaluating 'casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)')')"
TypeError: 'undefined' is not a function (evaluating 'casper.userAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)')')
答案 0 :(得分:2)
刚刚结束这个问题,这是CasperJS版本的问题。这里没有错(请参阅@Niko和@jnthnclrk的问题评论,原始海报)。