Insert time +15 minutes

Ask general questions here.
cs97jjm3
Posts: 7
Joined: Mon Jan 14, 2019 4:30 pm

Insert time +15 minutes

Post by cs97jjm3 » Wed Jul 17, 2019 10:53 am

hello i am testing a cancellations module which means i have to cancel a event before it happens in realtime (i know its a pain)

i have tried using excels now() formula which when imported in ranorex does not show as time format but as text like 04567289.

is there a simple way I can insert the time of insert say 1000 plus 15 minutes say 10:15


thanks in advance, please not i am not a coder.....

once again thanks in advance

James Murrell

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

Re: Insert time +15 minutes

Post by odklizec » Wed Jul 17, 2019 11:11 am

Hi,

Could you please specify where exactly you want to insert the time? Ideally, please post a Ranorex snapshot (NOT screenshot) of the input element.

Generally speaking, you can use DateTime and Now to add minutes to the actual time. You can use code lie this to get the actual time + 15m...

Code: Select all

    System.DateTime startDate = System.DateTime.Now;
    string curTimePlusMins = startDate.AddMinutes(15).ToShortTimeString();
To set the time to element of your choice, you can use either KeySequence or SetValue action.
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

cs97jjm3
Posts: 7
Joined: Mon Jan 14, 2019 4:30 pm

Re: Insert time +15 minutes

Post by cs97jjm3 » Wed Jul 17, 2019 11:27 am

thanks here is snapshot


the format must be 00:00 hh:mm
Attachments
time insert.rxsnp
(66.49 KiB) Downloaded 2 times

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

Re: Insert time +15 minutes

Post by odklizec » Wed Jul 17, 2019 11:45 am

Hi,

Basically, must create a repo element with xpath like this:
/dom[@domain='test.mywebroster.com']/?/?/form[@name='frmEditRequirement']//input[@name='txtTimeFrom']
Then you must assign repo element as argument of method like this:

Code: Select all

public static void SetTimePlusMinutes(RepoItemInfo repoElement)
    {
        System.DateTime startDate = System.DateTime.Now;
        string curTimePlusMins = startDate.AddMinutes(15).ToString("HH:mm");;
        repoElement.CreateAdapter<Ranorex.Unknown>(false).PressKeys(curTimePlusMins);	
    }
Hope this helps?
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

cs97jjm3
Posts: 7
Joined: Mon Jan 14, 2019 4:30 pm

Re: Insert time +15 minutes

Post by cs97jjm3 » Wed Jul 17, 2019 11:58 am

thanks for this:


silly question from me:


how do you assign repo element as argument of method

i only ever have used front end of Ranorex, nothing with actual code

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

Re: Insert time +15 minutes

Post by odklizec » Wed Jul 17, 2019 12:01 pm

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

cs97jjm3
Posts: 7
Joined: Mon Jan 14, 2019 4:30 pm

Re: Insert time +15 minutes

Post by cs97jjm3 » Wed Jul 17, 2019 12:58 pm

Thanks for this i will see if i can get working: and i will let you know the outcome


Thanks

cs97jjm3
Posts: 7
Joined: Mon Jan 14, 2019 4:30 pm

Re: Insert time +15 minutes

Post by cs97jjm3 » Wed Jul 17, 2019 1:30 pm

WOW: got it working:

Thanks for the code and the link which helped me learn.....

seriously you have saved me a major headache: and helped us provide better software

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

Re: Insert time +15 minutes

Post by odklizec » Wed Jul 17, 2019 1:34 pm

Hi,

Nice to hear you got it working. I'm glad I could help ;)
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