Forum Discussion

lavalleep's avatar
lavalleep
New Contributor
13 years ago

Export Project Suite Logs programmatically

Greetings everyone!



I've automated different projects that are all contained within the same project suite. As of now, the logs are exported manually and I was wondering if the functionnality could be applied in some way.



I've looked into adding an OnTestStop event with the proper method in it but can't find an actual exemple of a JScript function that could help me in this manner. What i've got so far is this:




function ExportResults()


{


  var FileName;


  FileName = "C:\\Export"; 


  Log.SaveResultsAs(FileName, 1);


}



The idea is to have the logs exported to an HTML format (second parameter set to 1).



Any help is welcome and thanks in advance :)

  • lavalleep's avatar
    lavalleep
    New Contributor
    Didn't read a second time before posting... the idea is to have the logs exported automatically at the specified path, hopes this makes it a little clearer :)
  • lavalleep's avatar
    lavalleep
    New Contributor
    The problem was resolved:



    Here is the solution written with JScript. I work on a VM and the only browser installed is Internet Explorer. By changing the value in the Browser.Item(), Mozilla or Chrome can be launch instead.




    /**


     * Exports to HTML format the project suite test execution results


     * Param showLogInBrowser (Boolean) - Open browser once the generation is successful


     */


    function ExportResults(showLogInBrowser)




      var fileName = "Somepath";


      try


      {


        Indicator.PushText("Exporting Test Logs to " + fileName);


        Log.SaveResultsAs(fileName, 1);


        Log.Message("Export completed succesfully!");


        


        if(showLogInBrowser)


          Browsers.Item(btIExplorer).Run(fileName + "\\index.htm");


      }


      catch(ex)


      {


        Log.Error(ex.Name + " " + ex.Description); 


      }


    }

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Patrick,


     


    Thanks for sharing the ready script with us! I hope it will be useful for TestComplete users.