18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Log html page after a fail

robyrobotrobyrobot Members
edited November -1 in Sahi - Open Source
Hi all,

it is possible to write down the content of a page after a fail occours ?

I tried with this

_writetoFile(document.getElementByTagName("html")[0].innerHTML, "myfile.html");

...

but I've obtained as a content of the file myfile.html this ..

document.getElementByTagName("html")[0].innerHTML;document.getElementByTagName("html")[0].innerHTML

Cheers

Roby

P.S: this is important for debug purposes, and hope to be possibile in future release, because in the log file it will no log the html of the page that make the test to fails. As an example it is possible to look at the log that the canoo web test will produce, where it is possible to access at the html page where the fails occours.

P.P.S: nevertheless it is a wonderfull testing tool ;-)
Tagged:

Comments

  • robyrobot wrote:
    Hi all,

    it is possible to write down the content of a page after a fail occours ?

    I tried with this

    _writetoFile(document.getElementByTagName("html")[0].innerHTML, "myfile.html");

    ...

    but I've obtained as a content of the file myfile.html this ..

    document.getElementByTagName("html")[0].innerHTML;document.getElementByTagName("html")[0].innerHTML

    Cheers

    Roby

    P.S: this is important for debug purposes, and hope to be possibile in future release, because in the log file it will no log the html of the page that make the test to fails. As an example it is possible to look at the log that the canoo web test will produce, where it is possible to access at the html page where the fails occours.

    P.P.S: nevertheless it is a wonderfull testing tool ;-)

    I found a solution by myself ... I will sare it with you :-))

    the solution is:

    var $html = document.getElementsByTagName("html")[0].innerHTML;
    ...
    and when you wnat to log the page use ...

    _debugToFile($html, "myfile.html");

    Hope this can help someone else

    Cheers

    Roby
  • Hi,

    Thats cool! but how do you make it trigger after a failure occurs?

    Regards,
    Pankaj
  • robyrobotrobyrobot Members
    edited July 2009
    Hi,

    Thats cool! but how do you make it trigger after a failure occurs?

    Regards,
    Pankaj

    well .. i create a function like this
    function dumpPage($path)
    {
    var $html = document.getElementsByTagName("html")[0].innerHTML;
    _debugToFile($html, $path, true);
    }

    and i call to it into a try catch block

    try
    {
    .. here your code if an assert occours it will be cached and page dunped ;-)
    }
    catch(e)
    {
    _log(e);
    dumpPage("c:\mydumpedpage.html");
    }
  • narayannarayan Administrators
    That is cool Roby. Thanks for sharing.
    But I think _writeToFile(xx.innerHTML, fileName) should also work. I think it is inconsistent if that does not work. Will have a look at it.

    Thanks,
    Narayan
  • robyrobotrobyrobot Members
    edited July 2009
    narayan wrote:
    That is cool Roby. Thanks for sharing.
    But I think _writeToFile(xx.innerHTML, fileName) should also work. I think it is inconsistent if that does not work. Will have a look at it.

    Thanks,
    Narayan


    Hi narayan,

    I tried with:

    _writetoFile(document.getElementsByTagName("html")[0].innerHTML, "c:\mylog.html");

    but I got the following content in the c:\mylog.html file:

    document.getElementsByTagName("html")[0].innerHTML

    it seems to write down the command instead of the content

    but ...


    if I wrote:
    var $content;
    var $html = document.getElementsByTagName("html")[0].innerHTML;
    _set($content, $html);
    _writeToFile($content, " c:\mylog.html", true);

    it works!

    Cheers

    Roby

    P.S: but for compiling from source code ... there's some other jars to get ? I trying with netbeans ide but some jars are missing :(
Sign In or Register to comment.