【问题标题】:swipe or scroll to bottom in appium - android在appium中滑动或滚动到底部 - android
【发布时间】:2017-01-01 00:27:02
【问题描述】:

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

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

但以上没有帮助。谁能建议我一些通用的解决方案?

【问题讨论】:

    标签: android selenium appium


    【解决方案1】:

    一般的解决方案是使用尺寸进行滚动。使用下面的代码

     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();在你的测试用例中。修改代码中给出的十进制值以满足您的要求

    【讨论】:

    • 这不是将屏幕滚动到底部。 :(
    • 修改driver.swipe(0, Startpoint,0,scrollEnd,1000)中的参数值;
    • 我修改了它们。它正在获取屏幕尺寸,但它不会在手机上滚动。
    • 我检查了,它在调试模式下运行,但运行程序,它失败了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-22
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 2014-12-12
    • 2018-02-27
    • 1970-01-01
    相关资源
    最近更新 更多