【问题标题】:Any way to access Console.log() Output from QTP?有什么方法可以从 QTP 访问 Console.log() 输出?
【发布时间】:2014-09-18 15:22:30
【问题描述】:

在 QTP 中,有没有办法查看 Javascript 应用程序正在向浏览器的调试器控制台写入什么?也就是说,通过 JS 调用 window.console.log() 写入的警告和错误。

此输出似乎没有直接流向 QTP 输出窗口。

提前谢谢...

【问题讨论】:

    标签: qtp hp-uft


    【解决方案1】:

    UFT 不支持浏览器中的 console 输出,但是您可以使用 UFT 的 EmbedScript 函数将控制台消息发送到您想要的任何地方。

    JS 示例:

    // OverrideConsole.js
    if (window.console) {
        console.error = function(msg) {
            // send error message to your output file
        }
        // ditto for any other functions you want
    }
    

    然后在测试的开头使用这一行:

    Browser("B").EmbedScriptFromFile("C:\OverrideConsole.js")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-19
      • 2011-06-10
      • 2015-01-16
      • 1970-01-01
      相关资源
      最近更新 更多