Definition by cases „If .. else” in recoding level (.rxrec)?

Ranorex Spy, Recorder, and Studio.
TestXYZ
Posts: 16
Joined: Thu Aug 29, 2013 12:55 pm

Definition by cases „If .. else” in recoding level (.rxrec)?

Post by TestXYZ » Mon Oct 14, 2013 7:12 pm

Hello,

Could I put if .. else or switch {case 1: case 2:… } in recoding file (*.rxrec)?

For example:

Code: Select all

If ($MyParameter == 1)
Then
{
   Mouse.click(Button1);
}
Else
{
   Validate(Attribute…);
   Mouse.DoubleClick(Button2);
}
It can only be implemented in UserCode, but not in recording, right? or any ideas? Many thanks!
Best Regards

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: Definition by cases „If .. else” in recoding level (.rxrec)?

Post by Swisside » Tue Oct 15, 2013 10:06 am

Hello

You can do that only in the usercode as you said but it works pretty nicely.


Could you tell me exactly what you are trying to do ?


Have a nice day

Boris
A simple thank you always does wonders !

TestXYZ
Posts: 16
Joined: Thu Aug 29, 2013 12:55 pm

Re: Definition by cases „If .. else” in recoding level (.rxrec)?

Post by TestXYZ » Tue Oct 15, 2013 11:28 am

Hi Boris,

Thanks for your post. Our application logic is in database. All recordings contain several actions (average 30-40) They are "Mouse Click", "Mouse DoubleClick" and "Validate" and so on…

I create alle recordings in a standard database. But if I run the test in other customized database, then 30% of these actions should not be executed, because the other database hat very different data and configuration bases. Some actions (e. g. selection value on list) I can use module parameter, but “Mouse Click on Dialog” or “Validation Text on Dialog” not. The dialog will not be displayed in the other database. The option “Enable Continue On Fail” costs performance.

I have put such actions to user code items then and added in code the “If .. else” condition. It works so far so on. But it is not easy to maintain. Because they cannot easy be merged to one user code item for our case and if the test goes wrong, I should check each methods in the user code. The cost of maintenances is higher than create a new one recoding for the special database.

It will be nice, to add conditions in record file directly...

Swisside
Posts: 92
Joined: Thu Oct 10, 2013 10:40 am

Re: Definition by cases „If .. else” in recoding level (.rxrec)?

Post by Swisside » Tue Oct 15, 2013 1:39 pm

Now I understand your problem.

For now I'm pretty sure, as you said, that it is impossible to add conditions/loops/etc to the .rxrec.

Moreover I totally agree with the use of Continue on fail which increases the time for each test.


How about using Report.Log in the usercode items to track errors ? Then if the test fails you directly know where it did. That would of course mean additional coding. The thing is it's the only way to do it as far as I know.
A simple thank you always does wonders !

TestXYZ
Posts: 16
Joined: Thu Aug 29, 2013 12:55 pm

Re: Definition by cases „If .. else” in recoding level (.rxrec)?

Post by TestXYZ » Wed Oct 16, 2013 12:04 pm

Hi Boris,

thanks for your reply. I would create new recordings for the special condition. But I hope, that we could use "conditional expression" in .rxrex directly in der higher version of Ranorex :wink:

Best regards

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

Re: Definition by cases „If .. else” in recoding level (.rxrec)?

Post by Support Team » Thu Oct 17, 2013 3:52 pm

Hello,

Unfortunately, we don't provide a possibility to create conditions inside a recording as posted by Boris.
This currently needs to done in User Code. We are evaluating a possible future implementation.

Would it be possible for you to move actions to a separate Test Case and enable or disable the Test Case based on a condition? The following code snippet would enable or disable a specific Test Case:
bool l_Test = function();
TestSuite.Current.GetTestCase("Testcase1").Checked = l_Test ;
TestSuite.Current.GetTestCase("Testcase2").Checked = !l_Test ;
Please take a look at this post that includes a sample solution:
http://www.ranorex.com/forum/starting-t ... t3899.html

Regards,
Markus (T)
.
Image

bru
Posts: 18
Joined: Thu Oct 31, 2013 11:22 am
Location: Linz / Austria
Contact:

Re: Definition by cases „If .. else” in recoding level (.rxrec)?

Post by bru » Thu Nov 07, 2013 10:22 am

Hi Support Team!

My suggestion for a possible future implementation of this feature:
Make it possible to set the "Enabled"-Property for an action to a variable!

In the usecase of TestXYZ he would set this variable to False when executing the test on a custom database.
All actions that have assigned "Enabled=$myCustomEnablingVar" (for example) would be disabled and would not be executed.

Maybe this is an elegant solution for this issue...?

Best regards,
Juergen

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

Re: Definition by cases „If .. else” in recoding level (.rxrec)?

Post by Support Team » Fri Nov 08, 2013 4:23 pm

Hello Juergen,

Thank you for your suggestion in this matter.

Regards,
Markus (T)
.
Image