Search code examples
qtphp-uft

Any way to access Console.log() Output from QTP?


In QTP, is there a way to see what the Javascript application is writing to the browser's debugger console? That is, the warnings and errors that are written via a JS call to window.console.log().

This output does not seem to be flowing directly to the QTP output window.

Thanks in advance...


Solution

  • The console output in the browser is not supported by UFT, however you can use UFT's EmbedScript function in order to send console messages to wherever you want.

    JS Example:

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

    Then use this line in the beginning of the test:

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