Page 1 of 1

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

Posted: Mon Oct 14, 2013 7:12 pm
by TestXYZ
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

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

Posted: Tue Oct 15, 2013 10:06 am
by Swisside
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

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

Posted: Tue Oct 15, 2013 11:28 am
by TestXYZ
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...

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

Posted: Tue Oct 15, 2013 1:39 pm
by Swisside
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.

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

Posted: Wed Oct 16, 2013 12:04 pm
by TestXYZ
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

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

Posted: Thu Oct 17, 2013 3:52 pm
by Support Team
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)

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

Posted: Thu Nov 07, 2013 10:22 am
by bru
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

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

Posted: Fri Nov 08, 2013 4:23 pm
by Support Team
Hello Juergen,

Thank you for your suggestion in this matter.

Regards,
Markus (T)