How to scroll scroll date until the desired element is visible in Selenium Appium Python

24 views Asked by At

How to scroll a date element until the desired value is visible. For example the default is 22 March 2007. I want to scroll the element to for example 1 January 1999.

Here is the UI:

enter image description here

What I've done:

    dob = driver.find_element(by=AppiumBy.XPATH, value="/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.View/android.view.View/android.view.View/android.view.View/android.widget.ScrollView/android.view.View[2]")
    dob.click()

    current_year = datetime.now().year
    current_month = datetime.now().month
    current_day = datetime.now().day

    default_year = current_year - 17

    year1 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value=str(default_year))
    year2 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="2000")
    year1.click()
    driver.scroll(year1,year2)

    time.sleep(2)

    month1 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value=str(current_month))
    month2 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="September")
    month1.click()
    driver.scroll(month1,month2)

    time.sleep(2)

    day1 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value=str(current_day))
    day2 = driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="29")
    day1.click()
    driver.scroll(day1,day2)

    time.sleep(2)
    driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value="Pilih").click()

But it didn't do anything, please help

0

There are 0 answers