在appium中滑动或滚动到底部-android [英] swipe or scroll to bottom in appium - android

查看:347
本文介绍了在appium中滑动或滚动到底部-android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用appium在Android应用程序中将滚动条滑动到底部? 我尝试使用

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 ?

推荐答案

通用解决方案将使用尺寸进行滚动.使用以下代码

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) {

                }    
          }

将此添加到我们的代码中,只需使用scroll();即可.在您的测试用例中.修改代码中给出的十进制值以满足您的要求

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

这篇关于在appium中滑动或滚动到底部-android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆