Forum Discussion

Wamboo's avatar
Wamboo
Community Hero
6 years ago

Get Unit name in script

Does anyone know the solution to this problem?   https://community.smartbear.com/t5/TestComplete-General-Discussions/How-to-find-the-script-unit-name/td-p/160177   How do I get the name of th...
  • Wamboo's avatar
    Wamboo
    6 years ago

    Hi

    Thank you for your answers. 

     

    TanyaYatskovska  this code refers to the name of the running function and not to the name of the file in which the function is stored.

     

    I found a solution how to find the name of the file from which the function is run.

     

     

    function retrievedNameRelatedUnit() {
         let testItemNameFull = Project.TestItems.Current.ElementToBeRun.Caption;
         var formatTestItemNameFull = testItemNameFull.split(/\Name-Full.split(/\Name-- /));
         return formatTestItemNameFull[1];
    }

     

    there is an array with the file name in the variable.

     

    You can use the file name (Unitu) to dynamically run the file by e.g. aqObject Object

     

    TY for all your help!