How to handle the calender in Makemytrip

I am trying to automate the Makemytrip app. And in this app i need to click on the Booking Date of the flight.
But i am not able to locate the object from the given Calender . Now how to click on the specific date.
Here is the screenshot of the UIAutomator

If you look carefully then you will able to find the month view in the inspector

However, the information is limited here and specific calendar date are not visible on inspector.

So In order to handle such cases ,you need to design your own custom date utility which tap on specific date.

Example for this case gh

@harshitj can you please explain me about this DateHandler
that is how to create this utility

Because that’s what i want

@Love_Soni I can explain the approach:

Step 1: Capture the calendar bounds.

Hint : Use element.getSize() and element.getLocation() for determining this.
Look at the highlighted rectangular section from my previous post comment Example : [30,576] [1050,1476] .

Step 2. Find out the Horizontal Width factor.

The width of calendar view is 1050…all dates are maintaining equal distance from each other. So if you divide the width by 7 then you will get the width factor. Example : total_width : 1050 width_factor=1050/7 =150

Step 3. Measure the Horizontal Coordinate(X Coordinate) for each column.

We have 7 column in a date calendar. Now If you want to tap on any date in 5th column then multiply width_factor * 5. i.e. 150 * 5= 750.(X Coordinate)

To add some precision use (width_factor * column_number) - element.getLocation().x.
(150 * 5)-30=720 (Final X Coordinate)

Step 4. Measure the Vertical Coordinate(Y Coordinate) for each Row.
The total height of Calendar view is 1476… Dates are square boxes of 150 x 150…Number of Rows are 5. With the use of these data you can easily determine Y coordinate.

This way you can tap on any date by using coordinates.

However, you have to look on several other things along with this implementation such as :

  1. Compare current date with the date of departure and restrict the users based on this.
  2. Handling of scrolls for the cases when the date of departure has couple of months.
1 Like

Thank you so much for explaining me

@harshitj one thing i want to ask tfrom you that
i use element.getSize() and
element.getLocation()
and i get (184, 184)
(448, 1081) respectively

But in the UIAutmator Bounds are different What should i do know is this a problem:

Can you share appium-server logs.

Here is the log file:
logs.txt (104.8 KB)

According to the logs,
you are using (“xpath”,"//android.view.View[@index=‘0’]) for finding the month view.
However, this xpath will return more than one element. So try to update your locator strategy.

You should try this to find calendar month view object through xpath : //android.support.v7.widget.RecyclerView/android.view.View[@index=0]

Also, I will recommend you to use Appium-Desktop for element inspection.
About Appium Desktop:

Download link:

1 Like

Hi
I Am not getting for finding Y cordinate Logic
Can u please elaborate