Android無線測試之—UiAutomator UiScrollable API介紹二

來源:互聯網
上載者:User

標籤:

快速滑動

一、快速滑動相關概念

1、步長:從一點滑動到另一點所用的時間

2、掃動次數:例如列表,要滑動多少次才能到底部,這個滑動次數就是掃動次數

二、相關API

傳回值 API 描述
boolean flingBackward() 以步長為5快速向後滑動
boolean filingForward() 以步長為5快速向前滑動
boolean flingToBeginning(int maxSwipes) 自訂掃動次數以步長為5快速滑動到起始
boolean flingToEnd(int maxSwipes) 自訂掃描次數以步長為5快速滑動到末尾

 

 

 

 

 

 

三、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="testFling";        androidId="1";        new UiAutomatorHelper(jarName, testClass, testName, androidId);    }        public void testFling() throws UiObjectNotFoundException{        UiDevice.getInstance().pressHome();        sleep(2000);                UiSelector l=new UiSelector().text("People");        UiObject p=new UiObject(l);        p.click();        sleep(2000);        UiScrollable scroll=new UiScrollable(new UiSelector().className("android.widget.ListView"));        scroll.flingForward();        sleep(3000);        scroll.flingBackward();        sleep(3000);        scroll.flingToEnd(5);        sleep(3000);        scroll.flingToBeginning(5);            }}
Demo.java

 

Android無線測試之—UiAutomator UiScrollable API介紹二

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.