Access Folder Name in the rxtst file

Ask general questions here.
Prad
Posts: 12
Joined: Tue Feb 21, 2012 11:50 pm

Access Folder Name in the rxtst file

Post by Prad » Mon Mar 26, 2012 6:37 pm

Hi ,

How can i access the parent folder name of the test case being executed ?

since our test cases are organized by categories in the rxtst file ,
and have corresponding config files organized in the same manner,

would like avoid parsing through multiple directories to get to the correct file

Did not see a parameter in TestSuite.current for this value ?


[folder] Category 1
TestCase 1
TestCase 2
TestCase 3
....
[folder] Category 2
TestCase 1
TestCase 2
TestCase 3
....
[folder] Category 3
TestCase 1
TestCase 2
TestCase 3
....

please advice

Regards,
Prad

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Access Folder Name in the rxtst file

Post by Support Team » Wed Mar 28, 2012 9:53 am

Hi,

You can use this code to get the parent folder name, or you can use the second one to print/get the whole test suite structure:

Input this code in one of your files of the actual test case.
first:
var TC = (TestCase)TestCase.Current;
      if (TC.Parent.GetType() == typeof (TestSuiteFolder) )
      {
        var parTC = TC.Parent;
        Report.Info (TC.Parent.DisplayName);
      }
Just input the code into a UserCode file of your solution.
second:
void ITestModule.Run()
    {
      Mouse.DefaultMoveTime = 300;
      Keyboard.DefaultKeyPressTime = 100;
      Delay.SpeedFactor = 1.0;
      
      TestSuite TS = (TestSuite)TestSuite.Current;
      
      PrintChildren(TS.TestSuiteEntry, 0);
    }
    
    void PrintChildren(TestSuiteEntry entry, int depth)
    {
      String whitespaces = "";
      for(int i=0;i<depth;i++)
        whitespaces += "--";
      
      foreach(TestSuiteEntry child in entry.Children)
      {
        Report.Info(whitespaces + child.DisplayName);
        PrintChildren(child, depth + 1);
      }
    }
I have also attached the created UserCode file.

Regards,
Markus
Ranorex Support Team
You do not have the required permissions to view the files attached to this post.