How can I scroll to an element in Appium? I'm using Android Native App

In latest APPIUM

I found that driver.scrollTo(“testing”) method is
deprecated. How can I perform scrollTo action using new way of doing
it? Please help.

From the documentation, I can see, we need to use MobileBy.ByAndroidUIAutomator. But, I’m not really sure how to use this .

1 Like


into last @Test public void scrollingToSubElement() {

1 Like


I’m new to Appium, not able to understand this function. Any documentation to go through before using this function. Please help.


Is there the same for the ruby version?

You can make your own scroll actions using the existing swipe method like this

def swipeFrom(startText, stopText) @startCords = wait{find(startText).location} @endCords = wait{find(stopText).location} swipe(start_x:@startCords[0],start_y:@startCords[1],end_x:@endCords[0],end_y:@endCords[1], duration:3000) end

1 Like

This would help you: How to get the co-ordinates to scroll up and down

Instead of native scroll method which takes text (not an element), I used this method to swipe to the element.

But if you want to scroll down to an element is because the element maybe isn’t in the screen, so the @endCords will not be find…

Am I right?

Ah right. Well there may be a better way to do this but I made a swipeDown method that goes like

def swipeDown

        @x = window_size[:width]/2
        @y = window_size[:height] - 200

        @startCords = [@x,@y]
        @endCords = first_text.location

        swipe(start_x:@startCords[0],start_y:@startCords[1],end_x:@endCords[0],end_y:@endCords[1], duration:3000)

and then I made a swipeToFindMethod

  def swipe_to_find(textParam)

    for i in 0..3
        if wait{find(textParam).displayed?} == true
          return true



You can change the for loop to however many times you want, but you don’t want it to keep searching forever

1 Like

I’m thinking in another way, however yet to try.

  • Get the page source before swipe down. Save the page source in a variable.
  • Swipe down once and again get the page source. Compare the current page source with the saved one. If both matches, you are in the end of the page.

Any thoughts?


If the element is in the middle of the page maybe this isn’t fair.

You could pass one element (swipe method is so imprecise with ms in real devices) and never find the page source saved :wink:

@slipy12: Sorry if I understand you correctly.
Find the element in the page, if not then perform swipe. Repeat this until you find an element or fail the test case in case you reached the end of the page without finding element as mentioned earlier.

Correct me if I am wrong.

Yes, yes, what I was saying is that you have to take care about which duration parameter you set because in real devices the swipe isn’t regular (sometimes is a little one, sometimes is larger), it depends of the cpu performance or memory load.

Is a good way to perform the swipe_to(element)

Got you and agree with you @slipy12

Try this :

MobileElement radioGroup = (MobileElement) wd

.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()"


"new UiSelector().text(\"+your_text+\"));");;

This link will help you :

1 Like

scrollTo() method has been deprecated.

So for the Android Native app, we can perform scroll with the UiScrollable and UiSelector classes.

Method 1:
String DESTINATION_ELEMENT_TEXT= "KUBO"; ((AndroidDriver) driver).findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()) .scrollIntoView(new UiSelector().text(DESTINATION_ELEMENT_TEXT))");

Method 2:
String APP_SCROLLVIEW = "android.widget.ScrollView"; String DESTINATION_ELEMENT_TEXT= "KUBO"; ((AndroidDriver) driver).findElementByAndroidUIAutomator("new UiScrollable(new UiSelector().className(APP_SCROLLVIEW)) .scrollIntoView(new UiSelector().text(DESTINATION_ELEMENT_TEXT))");


Android Python Swipe operation with condition to check if the element is there or not.

The below function continues to look for the locator till its found. It will repeatedly do swipe down & check for id (15 times)

Works perfectly for my android native app.

def android_is_visible(self, locator):
for _ in xrange(15):
    x = 1000
        value = self.get_element(locator).is_displayed()
        if value is True:
    except NoSuchElementException:
        self.driver.swipe(470, 1400, 470, x, 400)

Going to try this tomorrow

You can refer this video

Hi @sridhareaswaran
can you please help me out


one issue i faced that in this application

that it is accepting my inputs from purpose of call and selecting the field


but then we need to scroll page becuase we need to fill the response of call field .

once i scroll the page it is not taking inputs!

dr.swipe(0, 0, 50, 20, 100);



and my code is this , from green line is showing propose of call

and i am using java language over here