Pass parameters to code module

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

Pass parameters to code module

Post by c676228 » Thu Aug 13, 2015 2:33 am

Hi,

I am thinking to pass testcaseId parameter to AddUser code module.
So the code module could know which test case data needs to be loaded/run for the code module.

Thanks,
Betty

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

Re: Pass parameters to code module

Post by odklizec » Thu Aug 13, 2015 2:11 pm

Hi,

I'm not exactly sure what you want to achieve, but I think you should be able to use the approach described here:
http://www.ranorex.com/blog/sharing-dat ... to-another
All you need to do is to create a new module variable in your code module (via "New" menu or context menu accessible via right click in code module). 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

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

Re: Pass parameters to code module

Post by c676228 » Mon Aug 17, 2015 7:56 pm

Hi Pavel,

This is not what I am asking.

Say I have an excel sheet for testing login for a bunch of userId

testcaseId userId password
123 abc xxxx
124 svA XXYSSS
124 jdjdj dkddk
...
133 DDD SSSII
what I am thinking is pass different testcaseId to the code module, so it will know which row of data should be fetched and tested. Not all data rows in the excel files are tested, only specified rows.
For now I am using file name Testcase124_login.cs code module for the specific test case, which is not effective. I am thing a code module could be used by many test cases with a testcaseId passed when it is needed.

Regards,
Betty

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

Re: Pass parameters to code module

Post by Support Team » Wed Aug 26, 2015 4:14 pm

Hello Betty,

To pass information to your code modules, you can create a module variable. You can then link the variable to a data connector or to a global parameter.
Add New Module Variable.png
Add New Module Variable.png (9.63 KiB) Viewed 1014 times
Since, you would have to define the data set somehow, I would recommend looking into using ranges for your data connector. Which will limit the rows that get passed into your testcases.

for more information about ranges please see the following link:

http://www.ranorex.com/support/user-gui ... html#c3272

Thanks,
Hansel
.
Image

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

Re: Pass parameters to code module

Post by c676228 » Fri Aug 28, 2015 5:32 pm

Thanks Hansel.

I was thinking of creating a base class with TestCaseId variable etc. since almost all test modules/cases need this variable to extract data from excel data connector. Then my code module can inherit this base class if common variables like TestCaseId is needed.

I am using Range but it is with EPPlus. That might have some difference with Ranorex Data Range.
I haven't seen a solid sample by using Ranorex data range. I suggest your company to give sample code for each class if it is possible.

Thanks,
Betty