how to connect user code models

Ask general questions here.
strannik
Posts: 60
Joined: Tue Apr 29, 2014 3:00 pm

how to connect user code models

Post by strannik » Wed Oct 29, 2014 4:28 pm

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.
You do not have the required permissions to view the files attached to this post.

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

Re: how to connect user code models

Post by krstcs » Wed Oct 29, 2014 4:45 pm

Store it in a global parameter and validate the due date against that parameter.
Shortcuts usually aren't...

strannik
Posts: 60
Joined: Tue Apr 29, 2014 3:00 pm

Re: how to connect user code models

Post by strannik » Wed Oct 29, 2014 4:53 pm

Hi krstcs,

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

Thank you

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

Re: how to connect user code models

Post by krstcs » Wed Oct 29, 2014 5:02 pm

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.
Shortcuts usually aren't...

strannik
Posts: 60
Joined: Tue Apr 29, 2014 3:00 pm

Re: how to connect user code models

Post by strannik » Wed Oct 29, 2014 5:14 pm

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.

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

Re: how to connect user code models

Post by krstcs » Wed Oct 29, 2014 5:23 pm

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.
Shortcuts usually aren't...

strannik
Posts: 60
Joined: Tue Apr 29, 2014 3:00 pm

Re: how to connect user code models

Post by strannik » Thu Oct 30, 2014 8:22 pm

Thank you krstcs,
I did some reading and everything is Ok now.