Forum Discussion

shahid24's avatar
shahid24
Contributor
8 years ago

Selecting different area on a calendar at each run of keyword test to create a reservation.

Hi, I have a keyword test. I recorded the keyword test in which you schedule a reservation by dragging the mouse over dates and time on a calendar which displays a weekly view.

 

According to my test case I have to schedule a reservation on the calendar in a future date.

 

As my keyword test always books the reservation on the same date as originally recorded, if i run the test some days later it will not be able to create a reservation on the calendar.

 

When  i recorded the keyword test I selected a region on the calendar and dragged the mouse to make a reservation. This region cannot be then found after a few days as the calendar gets updated

 

Attached is a video snippet of my problem.

 

https://www.screencast.com/t/rdjTwAD7

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What you'll need to do is change your keyword test to be more dynamic.... rather than dragging to a set region based upon co-ordinates that are hardcoded in your test, you need to find the desired region every time and then use that for the drag.

     

    So, the way you're going to have to do this:

     

    1) Use some sort of finding methodology (FindChild, Find, etc. or even some custom code), find the region in your calendar that contains the desired dates.

    2) Calculate, based upon that found object, the co-ordinates for your drag

    3) Pass those co-ordinates into your Drag method.

     

    There's any number of ways to do a lot of this, but step 1 is going to depend a LOT upon the calendar component itself.  That's the dynamic piece that you'll need to work around.  You MIGHT need to dive into Script code to do a bit of this and then call that code from within your keyword test.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    I would suggest to assign the required date directly but not via drop-down visual selection.

    Quite often the following worked for me:

    -- Assign required date to some calendar's property (it may be .Value, .wText or some other one);

    -- Click the calendar to open drop-down. If you are lucky, drop-down will be opened with the required date been pre-selected;

    -- Press Enter (Sys.Desktop.Keys("[Enter]") ) to emulate date selection and make all linked jscript code to do its job.