• Android无线测试之—UiAutomator UiScrollable API介绍六


    向前与向后滚动API

    一、向前与向后滚动相关API

    返回值 API 描述
    boolean scrollBackward(int steps) 自动以步长向后滑动
    boolean scrollBackward() 以默认步长55向后滑动
    boolean scrollForward() 以默认步长55向前滑动
    boolean scrollForward(int steps) 自定义步长向前滑动

    二、API应用举例

    package com.testuiselector;
    
    import com.android.uiautomator.core.UiDevice;
    import com.android.uiautomator.core.UiObject;
    import com.android.uiautomator.core.UiObjectNotFoundException;
    import com.android.uiautomator.core.UiScrollable;
    import com.android.uiautomator.core.UiSelector;
    import com.android.uiautomator.testrunner.UiAutomatorTestCase;
    
    public class Demo extends UiAutomatorTestCase {
    
        /**
         * @param args
         */
        public static void main(String[] args) {
            
            String jarName, testClass, testName, androidId;
            jarName="demo2";
            testClass="com.testuiselector.Demo";
            testName="testScrollBackwardAndForward";
            androidId="1";
            new UiAutomatorHelper(jarName, testClass, testName, androidId);
    
        }
    
        public void testScrollBackwardAndForward() throws UiObjectNotFoundException{
            UiDevice.getInstance().pressHome();
            sleep(1000);
            
            UiObject people=new UiObject(new UiSelector().text("People"));
            people.clickAndWaitForNewWindow();
            UiScrollable scroll=new UiScrollable(new UiSelector().className("android.widget.ListView"));
            
            //向前滑动,默认步长55
            scroll.scrollForward();
            sleep(3000);
            
            //向前滑动,指定步长为5
            scroll.scrollForward(5);
            sleep(3000);
            
            //向后滑动,默认步长为5
            scroll.scrollBackward();
            sleep(3000);
            
            //向后滑动,指定步长为5000
            scroll.scrollBackward(5000);
        }
    }
    Demo.java


     

  • 相关阅读:
    Jquery想说爱你不容易
    关于css
    sass相关实例
    web前端学习之HTML
    web前端学习
    软件工程来换网前端设计
    关于前端开发的相关资料及例子
    四则运算
    自我介绍
    关于读完《软件工程》之后不解的问题
  • 原文地址:https://www.cnblogs.com/fsw-blog/p/4597779.html
Copyright © 2020-2023  润新知