Able to scroll in date picker using scrollable class but it is not holding up on the text value which is passed in the method

Able to scroll in date picker using scrollable class but it is not holding up on the text value which is passed in the method… Using this code

		List<WebElement> dates = driver.findElements(
				AppiumBy.androidUIAutomator("new UiSelector().resourceId(\"android:id/numberpicker_input\")"));
		System.out.println(dates);

		WebElement year = dates.get(2);
		year.findElement(AppiumBy.androidUIAutomator(
				"new UiScrollable(new UiSelector().scrollable(true).instance(2)).scrollIntoView(new UiSelector().text(\"2021\"))"));

		WebElement month = dates.get(1);
		month.findElement(AppiumBy.androidUIAutomator(
				"new UiScrollable(new UiSelector().scrollable(true).instance(1)).scrollIntoView(new UiSelector().text(\"June\"))"));

		WebElement date = dates.get(0);
		date.findElement(AppiumBy.androidUIAutomator(
				"new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text(\"21\"))"));

@Aleksei

Sometimes scroll does not work with such pickers on Android. I use tap above/below and check value way.

E.g. with date tap above “1” switches value to 31, tap “2” switches value to 2.

See on on your screenshot there are buttons in each number picker ->

I once had to do that in Python. Got the below code as a result. Probably not the fastest one, although reliable.

        current_year_text = year_wheel.find_element(AppiumBy.CLASS_NAME, TEXT_CLASS_NAME_BIRTHDAY_VALUE)
        button_year_dec, button_year_inc = tuple(
            year_wheel.find_elements(AppiumBy.CLASS_NAME, BUTTON_CLASS_NAME_BIRTHDAY_VALUE_CHANGE)
        )
        while True:
            current_year = int(current_year_text.text)
            if current_year == bdate.year:
                break
            if current_year > bdate.year:
                button_year_dec.click()
            else:
                button_year_inc.click()

@Aleksei can you provide some example because not able to find any related example to tap method for latest appium version.