UiScrollable:可滚动的控件,如果操作的控件需要滚动就可以使用UiScrollable
如:UiScrollable appsList=new UiScrollable(new UiSelector().className("android.view.View"));
appsList.setAsHorizontalList();
快速滚动 、获取列表子元素、获取或者设置滚动次数、向前向后滚动、设置水平垂直滚动方向、滚动到某个对象、滑动坐标的偏移量。
Public Constructors
UiScrollable(UiSelector container) 构造函数
Public Methods
boolean flingBackward()
Performs a backwards fling action with the default number of fling steps (5).
boolean flingForward()
Performs a forward fling with the default number of fling steps (5).
boolean flingToBeginning(int maxSwipes)
Performs a fling gesture to reach the beginning of a scrollable layout element.
boolean flingToEnd(int maxSwipes)
Performs a fling gesture to reach the end of a scrollable layout element.
UiObject getChildByDescription(UiSelector childPattern, String text)
Searches for a child element in the present scrollable container.
UiObject getChildByDescription(UiSelector childPattern, String text, boolean allowScrollSearch)
Searches for a child element in the present scrollable container.
UiObject getChildByInstance(UiSelector childPattern, int instance)
Searches for a child element in the present scrollable container that matches the selector you provided.
UiObject getChildByText(UiSelector childPattern, String text)
Searches for a child element in the present scrollable container.
UiObject getChildByText(UiSelector childPattern, String text, boolean allowScrollSearch)
Searches for a child element in the present scrollable container.
int getMaxSearchSwipes()
Gets the maximum number of scrolls allowed when performing a scroll action in search of a child element.
double getSwipeDeadZonePercentage()
Returns the percentage of a widget's size that's considered as a no-touch zone when swiping.
boolean scrollBackward(int steps)
Performs a backward scroll.
boolean scrollBackward()
Performs a backward scroll with the default number of scroll steps (55).
boolean scrollDescriptionIntoView(String text)
Performs a forward scroll action on the scrollable layout element until the content-description is found, or until swipe attempts have been exhausted.
boolean scrollForward()
Performs a forward scroll with the default number of scroll steps (55).
boolean scrollForward(int steps)
Performs a forward scroll.
boolean scrollIntoView(UiSelector selector)
Perform a scroll forward action to move through the scrollable layout element until a visible item that matches the selector is found.
boolean scrollIntoView(UiObject obj)
Perform a forward scroll action to move through the scrollable layout element until a visible item that matches the UiObject is found.
boolean scrollTextIntoView(String text)
Performs a forward scroll action on the scrollable layout element until the text you provided is visible, or until swipe attempts have been exhausted.
boolean scrollToBeginning(int maxSwipes)
Scrolls to the beginning of a scrollable layout element.
boolean scrollToBeginning(int maxSwipes, int steps)
Scrolls to the beginning of a scrollable layout element.
boolean scrollToEnd(int maxSwipes, int steps)
Scrolls to the end of a scrollable layout element.
boolean scrollToEnd(int maxSwipes)
Scrolls to the end of a scrollable layout element.
UiScrollable setAsHorizontalList()
Set the direction of swipes to be horizontal when performing scroll actions.
UiScrollable setAsVerticalList()
Set the direction of swipes to be vertical when performing scroll actions.
UiScrollable setMaxSearchSwipes(int swipes)
Sets the maximum number of scrolls allowed when performing a scroll action in search of a child element.
UiScrollable setSwipeDeadZonePercentage(double swipeDeadZonePercentage)
Sets the percentage of a widget's size that's considered as no-touch zone when swiping.
Protected Methods
boolean exists(UiSelector selector)
Used privately when performing swipe searches to decide if an element has become visible or not.
总结:
也即是对可以滚动的界面的一个滚动操作。
相应的官方链接:
http://developer.android.com/intl/zh-cn/reference/android/support/test/uiautomator/UiCollection.html