Page 1 of 1

Key sequence for DateTime format "YYYY-MM-DD HH-MM"

Posted: Fri Feb 05, 2016 7:29 pm
by gowthamp
Hello,
I am new to Ranorex and C#, I want to enter Key sequence of Date and Time for a name which could be deleted at end of test run.[Application doesn't support repetition of Name :( ]

I want to enter Key sequence of format "YYYY-MM-DD HH-MM" ,so that every time I run the test case it will provide unique name.

Re: Key sequence for DateTime format "YYYY-MM-DD HH-MM"

Posted: Mon Feb 08, 2016 2:07 pm
by odklizec
Hi,

You can try something like this...

Code: Select all

string curDate = DateTime.Now.ToString("yyyy-MM-dd HH-mm");

Re: Key sequence for DateTime format "YYYY-MM-DD HH-MM"

Posted: Mon Feb 08, 2016 4:41 pm
by gowthamp
Defined variable with string type.
"repo.Testcase.Title.PressKeys(""+variable+"", 100);" working fine.
This creates variable with required format.

In this testcase I have like to click on this variable after creating it.
How can I click on this item?

Thanks odklizec for your help in creating variable with DateTime format.

Re: Key sequence for DateTime format "YYYY-MM-DD HH-MM"

Posted: Mon Feb 08, 2016 7:13 pm
by odklizec
I'm afraid, I don't understand what exactly you want to achieve? If you just want to combine the code I posted with the keypress code, it should look like this...

Code: Select all

string curDate = DateTime.Now.ToString("yyyy-MM-dd HH-mm");
repo.Testcase.Title.PressKeys(curDate, 100);
You can then call this code from user code or code module.

Re: Key sequence for DateTime format "YYYY-MM-DD HH-MM"

Posted: Mon Feb 08, 2016 7:21 pm
by gowthamp
Part One Creation: I created variable with curDate.
After creating that I have save button which will save the variable with curDate value.

I will make few other clicks and will return back to this page.
Part Two : In that page I have to make a click on the variable curDate which was created earlier.

Example: I created variable with curDate value of "2016-02-08 14:10" and saved it.
After returning to this page, I have to click "2016-02-08 14:10" on this name.

Re: Key sequence for DateTime format "YYYY-MM-DD HH-MM"

Posted: Mon Feb 08, 2016 9:38 pm
by odklizec
OK, but you know, you can't click the variable, right? It would be much easier if you could post a Ranorex snapshot of the second page, so we can see what kind of element you want to click and its xpath. It's hard to suggest something reliable without detailed info about your AUT, the technology it's built with, etc.

In general, if the actions you are supposed to perform on second page are in different recording/code module than the one in which you created the date variable, you will have to store the date variable in global parameter, so you can access it from anywhere in your test. There are also other ways, but using global parameters is probably the easiest solution?

Re: Key sequence for DateTime format "YYYY-MM-DD HH-MM"

Posted: Mon Feb 08, 2016 10:04 pm
by gowthamp
Attached screenshot of row, sorry for not attaching Snapshot[its revealing all GUI of application].
I have to create shiftname with testShift+"YYY-MM-DD HH-MM" format.
After that I have to make changes to StartTime and EndTime which are 2nd and 3rd columns .

Then I have to click on ShiftName[testShift+"YYY-MM-DD HH-MM"] to edit it.

All the time, I will make changes in current page. In this scenario Date Variable may not need to be Global parameter.

Re: Key sequence for DateTime format "YYYY-MM-DD HH-MM"

Posted: Tue Feb 09, 2016 7:26 am
by odklizec
Well, without snapshot, there is not much I can do for you, except some general suggestions. What you need to do is to add a repository item with your created date time variable. How to create a repo item with variable you can learn here...
http://www.ranorex.com/support/user-gui ... html#c2970

In case the datetime string is located in the innertext attribute, the end of xpath should look like this...
//elementname[@innertext~$curDate]

Then you can simply drag&drop just created repo item to recording table and from the appeared context menu (after drop) select mouse click action.

That's all ;)