设置滚动方向
一、设置滚动方向相关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(); } }