How to loop test data set within a recording module

Ranorex Studio, Spy, Recorder, and Driver.
User avatar
sandamal
Posts: 28
Joined: Wed Jul 08, 2015 7:50 am

How to loop test data set within a recording module

Post by sandamal » Tue Jul 14, 2015 1:22 pm

Hi Please explain whether below sample scenario is possible with ranorex, Im dealing with an android app and with beginner knowledge on ranorex

there is username and password two text fields and login button.
I need to try different invalid combinations on it and validate the "Invalid credentials" message.
I need to bind excel data set and execute it.
but with my approach for each data combination row it needs to exit and re launch the application. is it possible to fetch the data without re launching the application like below.

[launch application]

{loop excel sheet each data row}
enter user name
enter password
press login button
validate error message
{end of last data row}

[exit]

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How to loop test data set within a recording module

Post by krstcs » Tue Jul 14, 2015 1:34 pm

It isn't possible inside a single module without going into user-code.

However, you should probably consider re-configuring your modules by splitting the individual, atomic actions in your current module into their own modules. Then just add them in the test case where you need them and use the test case to loop through what you want.

Remember, test cases in Ranorex Studio's Test Suite are nothing more than for-each loops that iterate over each row of data in the connected data set.

So, you could have these modules instead:
1. Enter_UserName (takes UserName as a variable)
2. Enter_Password (takes Password as a variable)
3. Click_LoginButton
4. Validate_ErrorMessage
5. Validate_SuccessfulLogin

Then, in your test suite it would look like this:

TEST-SUITE
-TestCase1: Failed_Login -> DataConnector (each row is one INVALID login attempt)
---Enter_UserName -> Bind to DataConnector.UserName
---Enter_Password -> Bind to DataConnector.Password
---Click_LoginButton
---Validate_ErrorMessage
-TestCase2: Successful_Login -> DataConnector (each row is one VALID login attempt)
---Enter_UserName -> Bind to DataConnector.UserName
---Enter_Password -> Bind to DataConnector.Password
---Click_LoginButton
---Validate_SuccessfulLogin
---{Logout here to setup for next attempt}


Your dataset (DataConnector) can contain all rows and you can limit each test case to just the rows it should use by using the filter settings at the bottom of the data connector's dialog. Or you can create individual data sets for each test case.

Doing the above will allow you to drop in these modules wherever you need them. You can also drop them into groups and use the groups instead.
Shortcuts usually aren't...

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

Re: How to loop test data set within a recording module

Post by odklizec » Tue Jul 14, 2015 1:37 pm

Hi,

You need to use data-driven approach. I would suggest you to start with this screencast:
http://www.ranorex.com/support/screencasts.html#c3896

And this user guide chapter:
http://www.ranorex.com/support/user-gui ... sting.html

Basically, you need to create test structure like this:

Code: Select all

[Test Suite]
|_launch application         - recording module - this module should be outside TC
|_[LoopTestCase] <------------ here should be attached your excel data connector
| |_enter user name          - recording module
| |_enter password           - recording module
| |_press login button       - recording module
| |_validate error message   - recording module
|_exit                       - recording module - this module should be outside TC
Excel sheet should have two columns (e.g. UserName and Password) and as many lines as you like (where each line represents one iteration).

Hope this helps?
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

conradb
Posts: 19
Joined: Thu Mar 10, 2016 12:00 pm

Re: How to loop test data set within a recording module

Post by conradb » Fri Apr 22, 2016 4:31 pm

Thanks, that also made it clear. I had the same question :-)
The "DATA" source is attached to the Testcase that you want to have run in a loop. All actions or step in that Testcase will get run for as many times as your data has rows. It was very easy in the UI for me to properly refactor my test case.
Makes perfect sense now. :D
pros:Powershell automation guru
cons:UI automation hacker/n00b
Conrad Braam