Code to break out of a Test Case

Ask general questions here.
Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Code to break out of a Test Case

Post by Fergal » Wed Sep 06, 2017 9:21 am

Hi,

I have a TC in this format:

TC
- Recording Module A
- Recording Module B
- Recording Module C
- Recording Module D

I'd like to insert a code module between Recording Module A and Recording Module B, that will end and pass the TC, if a certain element exists. What code can I use to break out of the TC and not run the subsequent recording modules.

Edit: Using Ranorex 6.2.1 on Windows 7

Thanks
Last edited by Fergal on Wed Sep 06, 2017 11:23 am, edited 1 time in total.

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

Re: Code to break out of a Test Case

Post by odklizec » Wed Sep 06, 2017 9:34 am

Hi,

I think the cleanest solution of your problem is enclosing modules B, C and D in a nested smart folder. Then you should setup a condition, which will run or ignore the smart folder, based of the variable/parameter filled via the code module you mentioned (placed before the smart folder with condition). I believe there is also a coded way to achieve what you want? But if I remember it correctly, it uses an internal API, which is not recommended to use ;) So using nested SF with condition is probably the best way.
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

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Code to break out of a Test Case

Post by Fergal » Wed Sep 06, 2017 11:22 am

Thanks for your suggestion and reply odklizec. Sorry but I should have said I am using Ranorex 6.2.1, so I don't think that's an option on this version.

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

Re: Code to break out of a Test Case

Post by odklizec » Wed Sep 06, 2017 11:45 am

Well, in this case, you still have two options...

You can still create a nested test case (placed after code module), and then disable/enable it from code, like this:

Code: Select all

TestSuite.Current.GetTestCase("TestCaseName").Checked = false;
And this sample skips all TestCase modules (uses internal API):
https://www.ranorex.com/forum/how-to-st ... tml#p24582
Hope this helps?
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

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: Code to break out of a Test Case

Post by Fergal » Wed Sep 06, 2017 1:38 pm

Thanks very much Pavel. Your first option looks perfect, will work on that and reply back if I have any issues / questions.