Want to generate user code to print the todays date

Download and share automation modules and examples.
reach2shrikant
Posts: 2
Joined: Wed Apr 04, 2018 9:15 pm

Want to generate user code to print the todays date

Post by reach2shrikant » Tue Apr 16, 2019 5:56 pm

I want to write a code which generate todays date and from that I have to generate the date coded password.

Which method I use out following two options:
1. New Method with argument 'RepoItemInfo'
2. New Method with argument 'Adapter'

Once the date is generated, I have to generate date coded passcode using following formula:
Password = (((Month*31)+(day*day))*137)+(((year-2000)*16)+5987)

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

Re: Want to generate user code to print the todays date

Post by odklizec » Wed Apr 17, 2019 7:38 am

Hi,

Basically, you can use something like this:
int curDateDay = System.DateTime.Now.Day;
int curDateMonth = System.DateTime.Now.Month;
int curDateYear = System.DateTime.Now.Year;
int password = (((curDateMonth*31)+(curDateDay*curDateDay))*137)+(((curDateYear-2000)*16)+5987);
As long as you don't want to use a repo element in your password obtaining method, you don't have to use any of the two arguments you mentioned.
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