javascript - 如何调试casperJS中的javascript函数

标签 javascript debugging phantomjs casperjs

如何在 CasperJS 中调试 javascript 函数(使用 evaluate)?

是否有类似于 alert() 的东西可用于在需要时在命令行上打印值?

最佳答案

尝试这样的事情:

// 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 Documentation

关于javascript - 如何调试casperJS中的javascript函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18178094/

相关文章:

javascript - 如何将特定的 imdb ID 复制并添加到另一个州?

phantomjs - 在 PhantomJS 中将旋转文本渲染为 PDF

python - 如何正确停止 phantomjs 执行

javascript - index.addObjects 抛出使用错误(Algolia)

javascript - 我需要启用 CSRF 保护吗?

javascript - 图表每次渲染时都会调整大小

python - PyCharm IDE 在调试 Python 读取小 pickle 文件时非常慢

javascript - Angular 1.2 的 debugInfoEnabled

c# - 如何配置 PhantomJSDriver 以尽可能模拟我的 Google Chrome 浏览器?

javascript - 修改函数内的javascript变量