当前位置:  开发笔记 > 编程语言 > 正文

在javascript中阅读firebug控制台

如何解决《在javascript中阅读firebug控制台》经验,为你挑选了1个好方法。

我正在寻找一种方法来读取记录到firebug控制台的最新命令.

例如,我可以做一些事情

console.debug('The most current request URI is /sweatsocks');

然后可以使用另一段(伪)代码

if (mostRecentConsoleEntry().endsWith('/sweatsocks')) {
  // do some stuff
}

作为调试语句的上下文将在测试中的代码中,并且控制台检查将在selenium脚本内完成.这将让我观察深埋在js函数中的信息以及在运行时构建的东西.



1> nickf..:

您可以覆盖该console.log函数以添加所需的任何额外功能.

var oldLog = console.log;
var lastLog;
console.log = function () {
    // do whatever you need to do here: store the logs into a different variable, etc
    // eg:
    lastLog = arguments;

    // then call the regular log command
    oldLog.apply(console, arguments);
};

这不是最防弹的解决方案,因为console允许printf样式语法:

console.log("%d + %d = %s", 1, 3, "four");

......但它可能是你的开始.

推荐阅读
雯颜哥_135
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有