question of ranorex code

Ask general questions here.
jecardenasri01
Posts: 23
Joined: Tue Feb 13, 2018 2:33 pm

question of ranorex code

Post by jecardenasri01 » Tue Mar 20, 2018 10:59 pm

how can I make ranorex by code take me the current date and time

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

Re: question of ranorex code

Post by odklizec » Wed Mar 21, 2018 8:39 am

Hi,

Current date could by obtained with this code:

Code: Select all

string dateFormat = "dd/MM/yyyy";
//get actual date
System.DateTime curDate = System.DateTime.Today;  
//convert date to string
string curDateStr= curDate.ToString(dateFormat); 
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

jecardenasri01
Posts: 23
Joined: Tue Feb 13, 2018 2:33 pm

Re: question of ranorex code

Post by jecardenasri01 » Wed Mar 21, 2018 5:39 pm

odklizec wrote:Hi,

Current date could by obtained with this code:

Code: Select all

string dateFormat = "dd/MM/yyyy";
//get actual date
System.DateTime curDate = System.DateTime.Today;  
//convert date to string
string curDateStr= curDate.ToString(dateFormat); 


but if I say I want to insert the value of the actual date I can do it in a text field?


for example in keepass I must write password "rx"; just so that "rx" does not appear if not the current date as I can do?

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

Re: question of ranorex code

Post by odklizec » Thu Mar 22, 2018 9:20 am

Hi,

I'm afraid, I don't quite understand what's your goal? To pass the current date to an element, you can either do this from code or from recording, using Set Value or Key sequence action.

Set Value is not ideal (and may actually fail) for web-based apps, where some inputs are using "on-mouse" and "on-key" events, which are not triggered by Set Value action. Hence it's better to use Key Sequence instead.

Please provide a small sample project/test suite (based of the keypass or any other publicly available app/web page), in which you show us your intention.
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