How to select month and date from the popup datepicker in karate

Viewed 341

I'm working on a project to automate a mobile application using karate and appium. I'm able to select the very next/previous three months and next/previous three dates from the popup date picker using normal click(). E.g. I'm able to select the previous 3 months like Mar, Feb, and Jan w.r.t the current/default month(i.e. Apr) and was able to select the next three months May, June, and July w.r.t the current/default month(i.e. Apr). similarly I'm able to select the previous dates like 29, 28, and 27 w.r.t the current/default date(i.e. 30). Now I'm facing an issue when I try to select a month other than those 3 months and the same issue with the date too. It throws an error saying "Element could not be located"

FYI - In the dom I'm able to inspect all the month and date elements I even tried with the following code, it isn't working it's failing to locate the element.

And mouse().move('//XCUIElementTypeButton[@label="Apr"]', '//XCUIElementTypeButton[@label="Oct"]').go()

Kindly correct me if I'm wrong, I doubt that since not all the months and dates are visible on the UI side, so they must be hidden and the tests are failing to locate those hidden elements. Would like to request you to provide your inputs/opinion on this issue.

enter image description here

enter image description here

1 Answers

Typically iOS date picker can be handled in 2 ways

Both involve identifying each date picker wheel uniquely without a label (ie. locator shouldn't have date/month/year values)

option 1:

calling input() in karate and pass the value you want to select

* driver.input(<Locator>, "Oct")

option 2:

calling mobile command in appium via script() in karate

* def datePickerId = driver.elementId(<Locator>)
* def arguments = {"order": "next", "offset": 0.15, "element": "#(datePickerId)"}
* driver.script("mobile: selectPickerWheelValue", arguments)

refer : https://github.com/appium/appium-xcuitest-driver#mobile-selectpickerwheelvalue

Related