swipe or scroll to bottom in appium - android

2019-06-02 16:48发布

How can I swipe scroll to bottom in an android app using appium? I tried using

driver.swipe(300,800,300,500,2);
driver.scrollTo("string")

But above did not helped. Can anyone suggest me some generic solution ?

1条回答
等我变得足够好
2楼-- · 2019-06-02 17:27

A generic solution will be scrolling using dimensions. use the below code

 public void scroll() throws IOException {
                  try {
                    Dimension dimensions = driver.manage().window().getSize();
                    System.out.println("Size of screen= " +dimensions);
                    int Startpoint = (int) (dimensions.getHeight() * 0.5);
                    System.out.println("Size of scrollStart= " +Startpoint );
                    int scrollEnd = (int) (dimensions.getHeight() * 0.2);
                    System.out.println("Size of cscrollEnd= " + scrollEnd);             
                    driver.swipe(0, Startpoint,0,scrollEnd,1000);           

                } catch (IOException e) {

                }    
          }

add this to ur code and simply use scroll(); in ur test case. Modify the decimal values given in the code to nmeet your requirements

查看更多
登录 后发表回答