Current Testcase Name

Class library usage, coding and language questions.
SteveBeck
Posts: 19
Joined: Thu Jul 27, 2017 8:27 am

Current Testcase Name

Post by SteveBeck » Thu Jul 27, 2017 9:19 am

Hi Guys,

I am trying to get the name of the test module that is currently running. I've found multiple references to old code and methods that I cannot access anymore like

Code: Select all

TestCase.Current
.

I can currently reach the Smart Folder level with

Code: Select all

TestSuite.CurrentTestContainer.ParentContainer.Name
, but cant get any deeper.

Any and all advice is appreciated.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Current Testcase Name

Post by odklizec » Thu Jul 27, 2017 9:38 am

Hi,

Try this code:

Code: Select all

	var curTestCase = (TestCaseNode)TestSuite.CurrentTestContainer;
	string tcName = curTestCase.Name;
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

SteveBeck
Posts: 19
Joined: Thu Jul 27, 2017 8:27 am

Re: Current Testcase Name

Post by SteveBeck » Thu Jul 27, 2017 12:42 pm

Thanks, I realised from this that I was using the wrong term! I was actually looking for the Module name, but i was able to get to that from looking at definitions provided by the test case node you provided.

Code: Select all

TestModuleLeaf.Current.Name
Was what I actually wanted to do.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Current Testcase Name

Post by odklizec » Thu Jul 27, 2017 12:57 pm

Nice to hear you found what you wanted! Actually, from the first read of your post, I thought you are looking for the recording/code module name, but subject stated "Current Testcase Name", so I provided TestCase-based code ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration