Hi and welcome here,
I think you need to start with learning and understanding
Ranorex Data Driven approach, described here:
http://www.ranorex.com/support/user-gui ... html#c2985
There is also a nice video tutorial, available here:
http://www.ranorex.com/support/screencasts.html#c3896
Basically, you need to replace that date string with
repository variable. So the xpath should look like this...
Code: Select all
@title='Enter Scripts' and @fulltype='Enter.Prescriptions.ScriptScreen']/container[@type='EnterPanel']/?/?/container[@caption=$actualDate]/?/?/text[@name~'formattedTextField']
Then you need to create a
Global Parameter (e.g.
actualDate), which you need to bind with the previously created repository variable (actualDate). All this is described in the above mentioned tutorials.
Now you need to do some coding.
Create a new Code module and put it in the very first [Setup] section of your test suite. Learn about Setup/Teardown regions here:
http://www.ranorex.com/support/user-gui ... html#c3003
This will make sure the actual date will be set as the very first action in your test. Eventually, you can put the code directly to Program.cs, but I think using Code module is a cleaner way.
Now about the code...
Below code should get the actual system date, modify its format to M/dd/yy format and save it to previously created Global Parameter
actualDate, which is connected to repository variable
actualDate. Please take it only as a rough sample! I did not test it, so it may require some tweaks. But I'm using something similar in my tests and it works fine.
System.DateTime dateOutput = System.DateTime.Now;
string dateFormat = "M/dd/yy";
string dateOutputStr = dateOutput.ToString(dateFormat);
TestSuite.Current.Parameters["actualDate"] = dateOutputStr;
That's probably all. If you run your test, it should search for xpath with the actual date, instead of hardcoded one. Hope this helps?