Hi community,
I have two test cases in Ranorex:
-TC1: Create a non-professional account with a form
RunApplication
Click Login
KeySequence $login
Click Password
KeySequence $password
-TC2: Create a professional account with a form
RunApplication
Click Login
KeySequence $login
Click Password
KeySequence $password
click Company
KeySequence $company
There is just an aditionnal variable in the second test case.
My variables are in an Excel file which is connected to test cases with an Excel Data Connector.
This is my Excel file:
------------------------------------------------
Type | Login | Password | Company
pro | ad1 | mp1 | google
nopro| ad2 | mp2 |
------------------------------------------------
I would like to make one test with the two test cases.
If i have nopro as type in Excel file, run actions
If i have pro as type in Excel file, run different actions
It is possible to make an if statement as Recording actions in Ranorex?
Thanks
Romainb25
IF statement as Recording actions?
Re: IF statement as Recording actions?
Hi,
At the moment, the only way how to add conditional running of steps within Recording module, is to convert the steps into user code and then add some conditions in code.
Another approach would be to create multiple TCs and run enable/disable them via code module placed before first (each) TC and using code described here:
http://www.ranorex.com/forum/data-bindi ... tml#p37602
At the moment, the only way how to add conditional running of steps within Recording module, is to convert the steps into user code and then add some conditions in code.
Another approach would be to create multiple TCs and run enable/disable them via code module placed before first (each) TC and using code described here:
http://www.ranorex.com/forum/data-bindi ... tml#p37602
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
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
-
- Posts: 65
- Joined: Wed Sep 24, 2014 7:47 am
- Location: Israel
Re: IF statement as Recording actions?
Hi
you might drop the pro/nonpro and just always click company and then enter the value in the Excel. just for nonpro it is an empty string, so Ranorex will not type anything in company, which is the same as a nonpro user would do.
you might drop the pro/nonpro and just always click company and then enter the value in the Excel. just for nonpro it is an empty string, so Ranorex will not type anything in company, which is the same as a nonpro user would do.
Re: IF statement as Recording actions?
We heavily use optional variables in user code to make our modules more versatile. We'll make an optional action for each field on a form so actions for the entire form only needs to be created once. It just looks to see if a variable has a value and if so it does the action, if not it skips that field. This is what it looks like:
If you're going to use this frequently as we do, you may want to add report.info for your actions so they show up on your report and in case of a failure you can see where it went wrong. For text fields we'll also usually set the value to blank as the first action to make sure there isn't already text in the field.
Hope this helps.
Code: Select all
if (!string.IsNullOrEmpty(varCompany))
{
repo.Company.Click();
repo.Company.PressKeys(varCompany);
}
Hope this helps.
Re: IF statement as Recording actions?
It works, thank you everibody!