ada*_*her 4 javascript firebug selenium
我正在寻找一种方法来读取记录到firebug控制台的最新命令.
例如,我可以做一些事情
console.debug('The most current request URI is /sweatsocks');
Run Code Online (Sandbox Code Playgroud)
然后可以使用另一段(伪)代码
if (mostRecentConsoleEntry().endsWith('/sweatsocks')) {
// do some stuff
}
Run Code Online (Sandbox Code Playgroud)
作为调试语句的上下文将在测试中的代码中,并且控制台检查将在selenium脚本内完成.这将让我观察深埋在js函数中的信息以及在运行时构建的东西.
您可以覆盖该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);
};
Run Code Online (Sandbox Code Playgroud)
这不是最防弹的解决方案,因为console允许printf样式语法:
console.log("%d + %d = %s", 1, 3, "four");
Run Code Online (Sandbox Code Playgroud)
......但它可能是你的开始.
| 归档时间: |
|
| 查看次数: |
4624 次 |
| 最近记录: |