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


    设置滚动方向

    一、设置滚动方向相关API

    返回值 API 描述
    UiScrollable setAsHorizontalList 设置滚动方向为水平滚动
    UiScrollable setAsVerticalList 设置滚动反向为纵向滚动
    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="testSetAs";
            androidId="1";
            new UiAutomatorHelper(jarName, testClass, testName, androidId);
    
        }
        
        public void testSetAs() throws UiObjectNotFoundException{
            UiDevice.getInstance().pressHome();
            sleep(1000);
            
            UiObject people=new UiObject(new UiSelector().text("People"));
            people.click();
            sleep(2000);
            
            UiScrollable scroll=new UiScrollable(new UiSelector().className("android.support.v4.view.ViewPager"));
            
            //设置为水平滚动
            scroll.setAsHorizontalList();
            scroll.scrollBackward();
            sleep(2000);
            scroll.scrollForward();
            sleep(2000);
            
            //设置为纵向滚动
            scroll.setAsVerticalList();
            scroll.scrollForward();
        }
        
    }
    Demo.java
  • 相关阅读:
    米洛个人修炼术:导致上班累成狗的三大主因
    米洛个人修炼术:如何倍增你的功力修行速度达成健康体魄
    米洛个人修炼术:注意这三方面,天天都早起
    米洛个人修炼术:情绪的四种常用处理方式,其实都是有问题的
    好公司和差公司的对比
    课程作业二
    课程作业一
    作业四
    寒假作业三
    寒假作业二
  • 原文地址:https://www.cnblogs.com/fsw-blog/p/4598118.html
Copyright © 2020-2023  润新知