1

How do I automate scrolling in a native Android application? For example, on a 'terms and conditions' page. I am using Appium with selenium webdriver.

  • Anirban - Can you accept answer if it helps you. So this question will no longer be in active queue. – NarendraC Sep 13 '16 at 4:59
1

The snippet below is not for any particular mobile screen size. It is fetching the actual screen size each time.

    public void scroller() throws IOException 
{
      Dimension dimensions = ad.manage().window().getSize();
      System.out.println("Size of Window= " +dimensions);
      int scrollStart = (int) (dimensions.getHeight() * 0.5);
      System.out.println("Size of scrollStart= " +scrollStart);
      int scrollEnd = (int) (dimensions.getHeight() * 0.2);
      System.out.println("Size of cscrollEnd= " + scrollEnd);             
      driver.swipe(0,scrollStart,0,scrollEnd,1000);           
      System.out.println("Screen Swiped " );
 }
0

Using python-client of appium:

def _find_by_scroll(self, item_name):

    item = self.driver.find_element_by_android_uiautomator(
        'new UiScrollable(new UiSelector().scrollable(true).instance(0)).getChildByText(new UiSelector().className("android.widget.TextView"), "'
        + item_name + '")')
    item.click()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.