0

evaluateCasperJS でJavaScript 関数を (を使用して) デバッグするにはどうすればよいですか?

alert()必要に応じてコマンドラインに値を出力するためにここで使用できるものに似たものはありますか?

4

1 に答える 1

11

次のようなことを試してください:

// add this to the top of the script
casper.on('remote.message', function(msg) {
  this.echo(msg);
})

casper.thenEvaluate(function() {
  // and then add this to the evaluate to print a value
  console.log('Testing...');
})

これを try-catch で使用するには、次を使用します。

casper.thenEvaluate(function() {
  try {
    throw "Some error...";
  } catch(err) {
    console.log(err);
  }
})

出典: CasperJS ドキュメント

于 2013-08-12T00:57:16.477 に答える