Assigning value from custom code - Current date

Ask general questions here.
dugovic.milan
Posts: 68
Joined: Wed Jun 29, 2016 1:19 pm
Location: Frankfurt, Germany
Contact:

Assigning value from custom code - Current date

Post by dugovic.milan » Thu Jul 28, 2016 8:49 am

I created my own user code on the level of my test suite and defined it as follows:

Code: Select all

string _Date = System.DateTime.Today.ToString("dd.MM.yyyy");
[TestVariable("14c53109-442b-4734-83ef-5ab3c0f13cd1")]
public string Date
{
	get { return _Date; }
	set { _Date = value; }
}
Afterwards, I was able to see that my variable "Date" is bound on the Module-level (%ModuleName%/VARIABLES - Variable labeled with yellow) and I was able to bind the Parameter on the Suite-level as well. Still not getting any value into my module variable. Any suggestions? Thanks :roll:
Last edited by dugovic.milan on Fri Jul 29, 2016 12:48 pm, edited 1 time in total.
Ranorex Explorer @DVAG
Support my Ranorex Ideas & Improvements
My current approach: Ranorex 9.2.0

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

Re: Assigning value from custom code - Current date

Post by krstcs » Thu Jul 28, 2016 3:34 pm

Where did you place the module?

A module has access (can be bound) to any data item (parameters or data connectors) for its parent test case and all ancestors, including the suite (global parameters only).

You have to bind the module variable to the correct data item and you have to make sure that the data item actually has a value.

The user guide explains this very well, I would suggest reading it: http://www.ranorex.com/support/user-guide-20.html
Shortcuts usually aren't...