UIScrollable的基本讲解

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




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Appium概述    appium 是一个自动化测试开源工具,支持 iOS, Android, Windows, Firefox OS平台上的原生应用, 纯web应用和混合应用。“移动原生应用”是指那些用iOS或者 Android SDK 写的应用(Application简称app)。“移动web应用”是指使用移动浏览器访问的应用(appium支持iOS上的Safari和Android上的 Chrome)。“混合应用”是指原生代码封装网页视图——原生代码和 web 内容交互。比如,像 Phonegap,可以帮助研发者使用网页技术开发应用,然    后用原生代码封装,这些就是混合应用。     更重要的是,appium是一个跨平台的工具:它允许测试人员在不同的平台(iOS,Android)使用同一套API来写自动化测试脚本,这样大大增加了iOS 和Android测试套件间代码的复用性。学习Tips    本系列课程所涵盖的内容,包括所有Appium APIs相关的讲解都是基于java语言,当然不需要测试学习者精通java语言,只需要稍微有些java基础就能轻松学习,比如,基本数据类型,循环控制结构,分支控制结构,java面向对象的概念等;    本系列课程的脚本案例编写是基于TestNG测试框架,测试项目使用Maven构建,课程内容中会对这些相关的基础知识点做简单介绍,没有基础的同学无需担心,为了尽可能得降低课程的学习难度,其他相关的工具用法只做简单介绍(够用为主)。
好的,我会为您讲解uiautomator2自动化脚本的相关内容。 首先,uiautomator2是一种基于Android平台的UI自动化测试框架,它可以模拟用户的操作,比如点击、滑动、输入等,可以帮助开发者快速地进行自动化测试。 下面是一个简单的uiautomator2自动化脚本示例: ```java public class SampleTest extends UiAutomatorTestCase { public void testDemo() throws UiObjectNotFoundException { // 启动被测试的应用 getUiDevice().pressHome(); UiObject allAppsButton = new UiObject(new UiSelector().description("应用列表")); allAppsButton.clickAndWaitForNewWindow(); UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true)); appViews.setAsHorizontalList(); UiObject testingApp = appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), "被测试的应用名称"); testingApp.clickAndWaitForNewWindow(); // 执行测试操作 UiObject username = new UiObject(new UiSelector().className(android.widget.EditText.class.getName()).index(0)); username.setText("testuser"); UiObject password = new UiObject(new UiSelector().className(android.widget.EditText.class.getName()).index(1)); password.setText("testpassword"); UiObject loginButton = new UiObject(new UiSelector().text("登录")); loginButton.clickAndWaitForNewWindow(); // 验证测试结果 UiObject welcomeText = new UiObject(new UiSelector().text("欢迎使用")); assertTrue("验证欢迎文本是否存在", welcomeText.exists()); } } ``` 这个脚本的作用是启动被测试的应用,输入用户名和密码,点击登录按钮,然后验证欢迎文本是否存在。 这个示例只是一个简单的例子,实际的uiautomator2脚本可能会更加复杂,需要根据被测试应用的具体情况来编写。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值