global failure step?
global failure step?
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!
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: global failure step?
Hi,
You can define a "Close Application" action in a recording. This recording can be added in the "Teardown region" in your test case as shown below. Regards,
Bernhard
You can define a "Close Application" action in a recording. This recording can be added in the "Teardown region" in your test case as shown below. Regards,
Bernhard
You do not have the required permissions to view the files attached to this post.
Re: global failure step?
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.
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: global failure step?
Hello,
You can use a "User Code" module to implement an if condition and add it to the teardown region.
Bernhard
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
Re: global failure step?
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!
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: global failure step?
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
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