Forum Discussion

tphillips's avatar
tphillips
Frequent Contributor
4 years ago
Solved

Log folder equivalent of Indicator.Clear()

Is there an equivalent of Indicator.Clear() for Log Folders? How can I add a Log folder to the outermost logs without having to call Log.PopLogFolder() lots of times in a loop?

 

For now the solution I have come up with is to pass a negative value (e.g. -1000) to the Log.CreateFolder() OwnerFolderID argument.

There must be a better way, right?

6 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    There must be a better way, right?

    Passing (-1) as the value for the OwnerFolderID is a documented way to create a folder at the top of hierarchy.

    Personally I usually ensure that the folder is 'popped' after its use is over.

    For the folder(s) that can be used throughout test code (for example, the folder that stores test context) I keep its id in a variable/array like in the example code https://support.smartbear.com/testcomplete/docs/reference/project-objects/test-log/log/appendfolder.html#example

     

    • tphillips's avatar
      tphillips
      Frequent Contributor

      I thought -1 is the default, which means the parent should be the last folder (unless the default folder is not set)

      Can we unset the default folder?

       

      OwnerFolderID

      Identifier of the test log’s folder where a new folder will be created as a subfolder. To get this identifier, use the CreateFolder or AppendFolder method (they will create the parent folder). If this parameter refers to a non-existent folder, is omitted or is set to -1 (the default value), the AppendFolder method will either create the folder in the default folder of the test log or append it to the test log outside of any other folder (if the default folder is not set). The default folder is the folder that is currently at the top of the folder stack which is populated during the script run. To push a folder to or pop it out of this stack, use the PushLogFolder or the PopLogFolder method correspondingly.

       

      Maybe I am missing something?

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        To say the truth, I also was confused with this section of documentation.

        On the one hand, documentation talks about about non-existent folder ID *or* set to -1. On the other hand, you are saying that value like -1000 always creates new folder outside of all existing folder's hierarchy...

        Also, according to the documentation, I am not sure that default folder can be 'unset' (i.e. set to default) by any other means than 'popping' all 'pushed' folders.

        I also not sure if it is possible to get an id of the 'system default' folder (i.e. the one that is used at the test start).

         

        sonya_m : Sonya, could you ask documentation team to clarify this section of documentation please?