1

ここで何が間違っているのかわかりません...

私のコード:

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)')')
4

1 に答える 1

2

質問を締めくくるだけで、CasperJSのバージョンの問題でした。ここには何も問題はありません (元の投稿者である @Niko と @jnthnclrk による質問コメントを参照してください)。

于 2013-01-31T12:21:19.787 に答える