skip iteration(s) for a data drive test case

Ask general questions here.
c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

skip iteration(s) for a data drive test case

Post by c676228 » Wed May 06, 2015 1:15 am

Hi,

I have a test case (add users) with data from an excel sheet. I want to be able to break out of the iteration if certain data in that iteration doesn't meet the criteria, say duplicated email address

action1
action2
.
.
action5
action6 is user code validation method in *.usercode.cs, if duplicate email error message UI element presents here, stop doing action7 to action 10 and start the next iteration. if not, continue with action 7 to 10 ( add this user to database)
.
.
action9
action10
How to achieve this in Ranorex?

Thanks,

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

Re: skip iteration(s) for a data drive test case

Post by odklizec » Wed May 06, 2015 8:17 am

Hi,

These action1...action10 are the actions in Recordings, right? So basically, you want to skip the remaining recording module steps if the one with UserCode fails? I believe the only way to achieve this is to convert the "remaining" steps to user code and use them as a part of the validation UserCode action. So if the validation fails, you can skip the remaining steps (using a condition in your validation code).

Here is a pseudo code explaining how your validation method should look like:

Code: Select all

    try  
    {   
      Validate.Attribute(repo.something.ViewInfo, "Text", "yourValue");
    }  
    catch (Ranorex.ValidationException)  
    {  
      return;
    }  
    action7
    ...
    action10
There is currently no way to perform conditional operations directly in recording module.
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

c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

Re: skip iteration(s) for a data drive test case

Post by c676228 » Wed May 06, 2015 7:08 pm

Hi odklizec,
Yes actions1 ... action10 are actions in Recordings.
That was I thought too since there is no direct conditional actions in recording module.
However when I try it approach
try {
//do validate
}
catch {
//do some cleanup actions
return; // return just simply terminate all the iteration including the current one, it won't go to the next //iteration
}

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

Re: skip iteration(s) for a data drive test case

Post by odklizec » Wed May 06, 2015 8:13 pm

Hi,

Make sure the test case (in which is placed your recording) has set the error behavior to "continue with iteration". Check this link for more details about error behaviors...
http://www.ranorex.com/support/user-gui ... html#c3028
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

c676228
Posts: 176
Joined: Mon Apr 06, 2015 5:40 am

Re: skip iteration(s) for a data drive test case

Post by c676228 » Wed May 06, 2015 11:59 pm

Got it. The support guy from Ranorex pointed that out too. It works now. :D
Thanks so much.

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

Re: skip iteration(s) for a data drive test case

Post by odklizec » Thu May 07, 2015 6:53 am

You are welcome ;)
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