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());
}
}

[uiautomator篇]recent的更多相关文章

  1. [uiautomator篇][1] 官网译文

    http://www.jianshu.com/p/7718860ec657 2016.07.25 20:59 字数 3675 Android UIAutomator浅谈 --------------- ...

  2. [uiautomator篇] python uiautomatorDemo

    #coding=utf-8 """ @version: 1.0 @author: @prerequisite: based on Python 2.7 @usage: 1 ...

  3. [uiautomator篇][exist 存在,但click错误]

    uiautomator定位页面元素是,定位存在的;但是click的时候,发现点的位置不对,(不知道是android系统的问题还是uiautomator的问题,初步怀疑是系统的问题)

  4. [uiautomator篇] 使用uiautomator需要导入uiautomator库

    1 修改依赖文件:build/gradle( 是在app目录下)而不是和app同级目录的build/gradle androidTestCompile 'com.android.support.tes ...

  5. [Uiautomator篇][2] UiDeviceAPI介绍

    1 https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html  http://www.cnb ...

  6. [UiAutomator篇][3] 打开音乐应用的测试脚本

    package qq.test; import android.content.Context; import android.content.Intent; import android.suppo ...

  7. [uiautomator篇] 找父亲节点和其他兄弟节点

    https://testerhome.com/topics/1250 Appium [已解决] UiSelector 如何根据节点定位到父节点 / 兄弟节点? liqing380 · 发布于 2014 ...

  8. [uiautomator篇] uiautoviewer 定位不到元素

    定位工具: Uiautomatorviewer 在我们的APP中,只有这一个页面,元素无法加载出来,其它的都没有什么问题.   提示的错误:Error while obtaining UI hiera ...

  9. [uiautomator篇] 获取当前页面的方法

    Uiautomator 在2.0之前的版本里就提供了getCurrentActivity()的方法,但返回内容不正确:2.0 版本今天尝试了下,还是返回有问题的: 有点没描述清楚啊,是在uiautom ...

随机推荐

  1. 本机运行x程序出现:Can't open display 原因及其解决方法(貌似非永久)

    http://blog.sina.com.cn/s/blog_53db572501016ma7.html 这是因为Xserver默认情况下不允许别的用户的图形程序的图形显示在当前屏幕上. 如果需要别的 ...

  2. Java——HashSet和TreeSet的区别

    HashSetHashSet有以下特点 不能保证元素的排列顺序,顺序有可能发生变化 不是同步的 集合元素可以是null,但只能放入一个null当向HashSet集合中存入一个元素时,HashSe ...

  3. C++拾遗(三)——函数

    函数的定义 C++是一种静态强类型语言,对于每一次的函数调用,编译时都会检查其实参,必须与形参类型相同,或可被转换为该类型. 参数传递 普通的非引用类型的参数通过复制对应的实参实现初始化.引用形参直接 ...

  4. LR常用函数汇总

    lr_start_transaction为性能分析标记事务的开始 lr_end_transaction为性能分析标记事务的结束 lr_rendezvous在 Vuser 脚本中设置集合点 lr_thi ...

  5. springMVC中jackson的使用(包含JsonFormat 时间格式)

    前台使用ajax,后台 springMVC Java下常见的Json类库有Gson.JSON-lib和Jackson等,Jackson相对来说比较高效,在项目中主要使用Jackson进行JSON和Ja ...

  6. Java动态代理之InvocationHandler最简单的入门教程

    网上关于Java的动态代理,Proxy和InvocationHandler这些概念有讲解得非常高深的文章.其实这些概念没有那么复杂.现在咱们通过一个最简单的例子认识什么是InvocationHandl ...

  7. 鼠标点击后的CSS3跑马灯效果

    代码: CSS: /*旋转木马*/ #rotate_container li { width: 128px; box-shadow: 0 1px 3px rgba(0, 0, 0, .5); posi ...

  8. 爬虫_python3_抓取猫眼电影top100

    使用urllib,request,和正则表达式,多线程进行秒抓,以及异常处理结果: import urllib,re,json from multiprocessing import Pool#多进程 ...

  9. spark 省份次数统计实例

    //统计access.log文件里面IP地址对应的省份,并把结果存入到mysql package access1 import java.sql.DriverManager import org.ap ...

  10. C#在透明窗体WinForm上面画图(电子尺小工具的实现)

    前几天要做一个微信调一调的外挂,里面用到了尺子测量距离,然后就自己下载了一个电子尺,最近要升级我的跳一跳外挂,然后就准备自己做一个电子尺,嵌入到我的外挂里面,在嵌入到我的外挂之前,我自己做了一个完整版 ...