colin
colin

Reputation: 613

Console output to HTML File

Basically I'm running some automated tests using TestNG.

I'm using ITestListener to give real-time results of my tests status but this is outputted to the console.

Is there anyway of outputting the information on the console to a HTML file so I can view the progress from the html file?

I'm planning to create a HTML style report for my own benefit so more specifically would it be possible to place to output to specific parts of the HTML Report I create?

Overall I'm trying to achieve is a HTML file that I can open on Chrome while my tests are running and with an automatic refresh I can view the progress of the tests.

Upvotes: 0

Views: 1966

Answers (1)

Andreas Brunnet
Andreas Brunnet

Reputation: 732

I came up with a solution that uses a small amount of JavaScript to update your browser window: Your major file would be:

<html>
<head>
    <script>
        function loadContentFile()
        {
            document.getElementById("content").innerHTML='<objecttype="type/html" data="content.html"></object>';
        }
        window.onload = setInterval(loadContentFile, 1000);
    </script>
</head>
<body>
    <div id="content"></div>
</body>
</html>


Edit:
Your Java program would write to a file called content.html. Just like you have done before. Nothing changes there. The "magic" happens by calling the index.html instead of the content.html. The index.html file when opened with a browser periodically loads the content of the content.html file thus realising a automatic reload of the page.

Conclusion:
You have a folder containing the index.html and content.html. Your browser calls the index.html. Your Java program writes to the content.html.

Upvotes: 1

Related Questions