Forum Discussion

amithsid's avatar
amithsid
Contributor
11 years ago

Need assistance in creating a log

Hello,



I have automated a testplan and now I need to work on the reporting part.

I want a log folder to be created in the name I specify and all the screenshots I take should be in the same folder with the image name as the step number.

Can anyone tell how to start with it? I am using JS Scripting.



Thank you,

Amith n g
  • Here is an example of 2 functions which do what you want and an example of testcase which uses these functions. The result log will look like in the attachment.




    var STEP = 1;


    var TC_ID;


     


    function Step(sDescription)


    {


        var oAttr;


        oAttr = Log.CreateNewAttributes();


        oAttr.Bold = true;


        STEP_ID = Log.CreateFolder("***Step #" + STEP + ": '" + sDescription + "'", "", pmNormal, oAttr);


        Log.PushLogFolder(STEP_ID);


    }


     


    function EndStep(sExpected)


    {


        Log.PopLogFolder();


        Log.Message("***Expected: '" + sExpected + "'");


        STEP++;


    }


     


    function testcase1()


    {


      Step('First step of the test case 1');


        Log.Message('Some actions');


        Log.Picture(Sys.Desktop.Picture(), 'Screenshot of the desktop');


      EndStep('Expected result of the step #1');


      


      Step('Second step of the test case 1');


        Log.Message('Some actions');


        Log.Picture(Sys.Desktop.Picture(), 'Screenshot of the desktop');


      EndStep('Expected result of the step #2');


      


      Step('First step of the test case 1');


        Log.Message('Some actions');


        Log.Picture(Sys.Desktop.Picture(), 'Screenshot of the desktop');


      EndStep('Expected result of the step #1');


      


    }

  • karkadil's avatar
    karkadil
    Valued Contributor
    Here is an example of 2 functions which do what you want and an example of testcase which uses these functions. The result log will look like in the attachment.




    var STEP = 1;


    var TC_ID;


     


    function Step(sDescription)


    {


        var oAttr;


        oAttr = Log.CreateNewAttributes();


        oAttr.Bold = true;


        STEP_ID = Log.CreateFolder("***Step #" + STEP + ": '" + sDescription + "'", "", pmNormal, oAttr);


        Log.PushLogFolder(STEP_ID);


    }


     


    function EndStep(sExpected)


    {


        Log.PopLogFolder();


        Log.Message("***Expected: '" + sExpected + "'");


        STEP++;


    }


     


    function testcase1()


    {


      Step('First step of the test case 1');


        Log.Message('Some actions');


        Log.Picture(Sys.Desktop.Picture(), 'Screenshot of the desktop');


      EndStep('Expected result of the step #1');


      


      Step('Second step of the test case 1');


        Log.Message('Some actions');


        Log.Picture(Sys.Desktop.Picture(), 'Screenshot of the desktop');


      EndStep('Expected result of the step #2');


      


      Step('First step of the test case 1');


        Log.Message('Some actions');


        Log.Picture(Sys.Desktop.Picture(), 'Screenshot of the desktop');


      EndStep('Expected result of the step #1');


      


    }

  • chrisb's avatar
    chrisb
    Regular Contributor
    You could also post the images directly to the test log when an error occurs. That way you have a screenshot in the log file at the failed step and less work implementing your logging. You may of course have a need to segregate your images in another directory.



    See this page for how to post a message to the log and for JScript examples: http://support.smartbear.com/viewarticle/55595/



    See here for posting an image to the log:

    http://support.smartbear.com/viewarticle/56283/