How to select current/today's date dynamically?

Class library usage, coding and language questions.
Posts: 11
Joined: Fri Jul 03, 2015 5:35 pm

How to select current/today's date dynamically?

Post by sunil.pandey » Wed Jul 08, 2015 11:43 am


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


User avatar
Ranorex Guru
Ranorex Guru
Posts: 7211
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » Wed Jul 08, 2015 11:55 am


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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Posts: 111
Joined: Fri Jul 03, 2015 9:18 am

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

Post by jma » Wed Jul 08, 2015 12:49 pm

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);

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

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

Post by krstcs » Wed Jul 08, 2015 4:28 pm

As I said in the other thread, it really sounds like you need to read the user guide.

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