Page 1 of 1

How to select current/today's date dynamically?

Posted: Wed Jul 08, 2015 11:43 am
by sunil.pandey
Hi,

Can anybody please help me to understand "how to select current/today's date dynamically?"

Regards,
Sunil

Re: How to select current/today's date dynamically?

Posted: Wed Jul 08, 2015 11:55 am
by odklizec
Hi,

Select where? Could you please be more specific? It would be much easier to help you with some more detailed description of your task and GUI ;) Ranorex Snapshot of your "date" selection GUI would be particularly useful here.

Generally speaking, you need to get the current date (via code), and then somehow select/set that date in your GUI. But it's hard to tell how without deeper knowledge of your GUI.

Re: How to select current/today's date dynamically?

Posted: Wed Jul 08, 2015 12:49 pm
by jma
Hello Sunil,

as Odklizec has already mentioned we would need some more detailed information about the specific UI element which stores the date information.

If you take a look at the KeePass application as an example you could directly set the value of the corresponding DateTime-Element using a User Code Action.

You can get the current date of your local machine via the property System.DateTime.Now.

Code: Select all

 public void SetCurrentDate()
 {        	
    System.DateTime currentDate = System.DateTime.Now;
        	
    repo.EntryForm.DateTime.Element.SetAttributeValue("Value", currentDate);
 }
Regards,
Johannes

Re: How to select current/today's date dynamically?

Posted: Wed Jul 08, 2015 4:28 pm
by krstcs
As I said in the other thread, it really sounds like you need to read the user guide. http://www.ranorex.com/support/user-guide-20.html

This will explain how to use Ranorex and how to use XPath. Check it out and if you have questions after that, ask away.


Also, when you have issues, please include the following:

Ranorex version
Windows version
XPath of element, if applicable
User code, if applicable
Demo project that shows the issue
Ranorex snapshot of the element in question (note, this is NOT a screenshot)