Page 1 of 1

how to connect user code models

Posted: Wed Oct 29, 2014 4:28 pm
by strannik
Hi all,

The system generates due date which is 90 days ahead of system date. I need to validate that this date is correct and we have current date in our system. I have wrote user code which converts current date to due date but I don't know how to connect or combine them. If this dates would be on one page it would be just one user code but they are on different pages.

User code model which takes current date and adds 90 dates to it:
var repo = US094Repository.Instance;

System.DateTime td=Convert.ToDateTime(repo.WebDocumentDEVMode70575Guidewi.TopFrame.SystemClockSystemClockScreenDate.Value.ToString());
Report.Log(ReportLevel.Info, "systemDate", td.ToString());

System.DateTime newtd = td.AddDays(90);
Report.Log(ReportLevel.Info, "Activity Date", newtd.ToShortDateString());

user code model which verifies that due date is correct:
System.DateTime ww=Convert.ToDateTime(repo.WebDocumentDEVMode70575Guidewi.TopFrame.PolicyFileActivityCAAActivityScreenA.InnerText.ToString());
Report.Log(ReportLevel.Info, "WebDate", ww.ToString());

Now I need to verify that one date = second and connect them.

Re: how to connect user code models

Posted: Wed Oct 29, 2014 4:45 pm
by krstcs
Store it in a global parameter and validate the due date against that parameter.

Re: how to connect user code models

Posted: Wed Oct 29, 2014 4:53 pm
by strannik
Hi krstcs,

I never did it before could you please let me know how to do that? Do I need code models?

Thank you

Re: how to connect user code models

Posted: Wed Oct 29, 2014 5:02 pm
by krstcs
If you are using Ranorex Studio:

1. Right-click on the Test Suite's name at the top of the test case tree in the RXTST file.
2. Select "Global Parameters".
3. Add the parameter to the top table (name it the same as the variable in the modules).
4. Click OK.
5. Bind the parameter to the module or modules that are doing the work.


The module that SETS the value should be before the module that CONSUMES the value, in the test suite.

Re: how to connect user code models

Posted: Wed Oct 29, 2014 5:14 pm
by strannik
thank you,
I don't understand how I will use code models with it. I can make due date variable through Get Value function and assign Set value to current date with the same variable but current date is not = to due date.

Re: how to connect user code models

Posted: Wed Oct 29, 2014 5:23 pm
by krstcs
I'm sorry, I don't understand what you're having trouble with. This is pretty basic, I'm not sure how to make it any simpler. Have you read the User Guide?


The modules can be user code or recording modules. If you are using user-code and don't understand this stuff, then I would suggest doing a lot more learning.


Store the value in the variable in the first module. If you need to add 90 days to it, then do it here. This variable is bound to the global parameter you create.

In the second module, compare the variable to the value that is displayed on screen. This variable is ALSO bound to the global parameter.

Re: how to connect user code models

Posted: Thu Oct 30, 2014 8:22 pm
by strannik
Thank you krstcs,
I did some reading and everything is Ok now.