zoukankan      html  css  js  c++  java
  • [uiautomator篇]recent

        def Recent(self):
            d = Device('9410519008004c22098b')
            displayWidth = int(d.info.get("displayWidth"))
            displayHeight = int(d.info.get("displayHeight"))
            d.press.recent()
            if d(text="No recent items").wait.exists(timeout=2000):
                print "Cleared recent items"
                return True
            if d(descriptionContains="Dismiss").wait.exists(timeout=2000):
                for i in range(50):
                    if d(text="CLEAR ALL").wait.exists(timeout=2000):
                        d(text="CLEAR ALL").click()
                        if d(description="Apps list",index=3).wait.exists(timeout=2000):
                            print "Cleared recent items"
                            return True
                        else:
                            print "Fail to clear recent items" 
                            return False
                    else:
                        d.swipe(displayWidth/2,displayHeight/4,displayWidth/2,3*displayHeight/4,steps=30)
                        i+=1
                else:
                    print "Fail to find CLEAR ALL "
                    return False
            else:
                print "EXCEPTION CLEAR RECENT ITEMS"
                return True

    java version

    package com.yang.clicktest;
    
    
    import com.android.uiautomator.core.UiDevice;
    import com.android.uiautomator.core.UiObject;
    import com.android.uiautomator.core.UiObjectNotFoundException;
    import com.android.uiautomator.core.UiSelector;
    import com.android.uiautomator.testrunner.UiAutomatorTestCase;
    import android.os.RemoteException;
    
    public class UiClickTest4 extends UiAutomatorTestCase {
        
        public void test() throws RemoteException, UiObjectNotFoundException, InterruptedException{
            
            UiDevice.getInstance().pressRecentApps();
            UiObject recentapp = new UiObject(new UiSelector().resourceId("com.android.systemui:id/dismiss_task"));
                    
            do{
                recentapp.waitForExists(2000);            
                if(recentapp.exists()){
                    recentapp.swipeLeft(5);
                }                
            }while(recentapp.exists());        
        }    
    }
  • 相关阅读:
    Android入门第六篇之ListView (一)
    STL 二分查找三兄弟(lower_bound(),upper_bound(),binary_search())
    fastjson 之常见的数据类型与json的相互转换
    Jetty:配置安全
    xml文件格式例如以下
    《编程珠玑》---笔记。浏览此文,一窥此书。
    【Github教程】史上最全github用法:github入门到精通
    SSL连接建立过程分析(1)
    ant 安装
    GMM的EM算法实现
  • 原文地址:https://www.cnblogs.com/liuzhipenglove/p/7196404.html
Copyright © 2011-2022 走看看