global failure step?

Ranorex Spy, Recorder, and Studio.
hporter
Posts: 35
Joined: Wed Jan 23, 2013 4:49 pm

global failure step?

Post by hporter » Fri Jan 25, 2013 6:23 pm

Hi, the app I am automating with Ranorex is browser-based, and is an iterative test. The test case is predicated upon a brand-new browser loading with each iteration. One problem I am seeing is if a step fails within the iteration, the browser instance persists, and a new browser is loaded (I have it set to 'continue with iteration'). I want to define global behavior where, if there's any failure within the iteration, processkill is called on iexplore, and the next iteration proceeds. Is there a way to define such global behavior? Thanks!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: global failure step?

Post by Support Team » Mon Jan 28, 2013 4:58 pm

Hi,

You can define a "Close Application" action in a recording.
CloseApplication.png
CloseApplication.png (8.69 KiB) Viewed 1035 times
This recording can be added in the "Teardown region" in your test case as shown below.
TestSuite.png
TestSuite.png (8.28 KiB) Viewed 1035 times
Regards,
Bernhard
.
Image

hporter
Posts: 35
Joined: Wed Jan 23, 2013 4:49 pm

Re: global failure step?

Post by hporter » Mon Jan 28, 2013 6:13 pm

Thank you very much for your reply. That is indeed useful, but in my case I need something slightly different. In my situation, it's more of a conditional teardown. Here's my example: my test case has 10 steps, with 8 overall iterations. Let's say I'm on the 3rd iteration, 8th step - it fails. Now it starts on the 4th iteration, only there's an instance of the browser still open (and my test NEEDS to open a fresh instance of the browser). Is there some global variable that I can define that says, "if any step within any instance fails, do something (i.e. killprocess) and start the next instance"? I am working around this by adding a killprocess step at the start of the test case, but it would be better the other way. Thanks again.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: global failure step?

Post by Support Team » Tue Jan 29, 2013 6:14 pm

Hello,

You can use a "User Code" module to implement an if condition and add it to the teardown region.
if(TestCase.Current.Status.ToString().Equals("Failed"))
{
   var repo = CloseIEInTeardownRepository.Instance;
   var testAutomationToolsRanorexAutomati = repo.TestAutomationToolsRanorexAutomati;

   Host.Local.CloseApplication(repo.TestAutomationToolsRanorexAutomati.Self);
   Host.Local.OpenBrowser("www.ranorex.com", "IE", "", false, false);			   	
}
Regards,
Bernhard
.
Image

hporter
Posts: 35
Joined: Wed Jan 23, 2013 4:49 pm

Re: global failure step?

Post by hporter » Wed Jan 30, 2013 4:57 pm

Thank you for the reply. I'm not much of a programmer...could you be more specific as to how to go about this? A step-by-step would be extremely helpful; thanks in advance!

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: global failure step?

Post by Support Team » Wed Jan 30, 2013 5:26 pm

Hello,

There is a very good description how use Code Modules in Ranorex Studio. Please find this in the section Lesson 7: Code Modules in our user guide.

Regards,
Bernhard
.
Image