android自动化测试-UiAutomator常用类
来源:互联网 发布:javascript 测试 编辑:程序博客网 时间:2024/06/01 20:39
前面总结了uiautomator的使用方法:
android自动化测试-UiAutomator使用入门
这里对我们写脚本时常用的一些类进行总结:
UiDevice类:
1.takeScreenshot(File storePath)
这个函数可以进行屏幕截图,但是呢,必须是4.2以上设备!而如果是虚拟机,你需要在启动安卓虚拟机时,先点击下edit按钮,查看Use Host GPU是否勾选,没有勾选就勾选,然后点击ok!返回后启动模拟机即可!同时呢,storePath这也有问题,应该是storeFile才更合适,就是说这个参数不是存储截图的目录,而是文件的路径!比如:/mnt/sdcard/Screenshot.png!而不是/mnt/sdcard/!
2.click(int x, int y)
点击屏幕上的一个点!x,y分别是其坐标,单位是像素吧!我的感觉!不过,我觉得这名起的……
3.press……
这个有很多,比如:pressBack()、pressHome()等;
4.setOrientationLeft()、setOrientationNatural()、setOrientationRight()
屏幕左转,恢复正常,右转等!
5.waitForWindowUpdate(String packageName, long timeout)
等待屏幕更新,A界面没有元素C,而B界面有!那么在A界面,使用这个函数,参数为元素C,如果转到B界面,返回true!就是说第一个参数是当前界面没有的类,而新界面有的类!
6.wakeUp()
唤醒!
7.swipe(int startX, int startY, int endX, int endY, int steps)
滑动,从一个点到另一个点!steps是每次滑动的尺度大小!
UiCollection
1.getChildByDescription(UiSelector childPattern, String text)
从Uiselector筛选出的元素集中挑出所要的元素,其中的text是描述内容!UiSelector是查找符合其描述的元素。再简单点,UiSelector找到一堆元素,然后再从里面找到符合描述的元素!以下的2、3 与其相似!
2.getChildByInstance(UiSelector childPattern, int instance)
3.getChildByText(UiSelector childPattern, String text)
4.getChildCount(UiSelector childPattern)
获得符合UiSelector描述的元素的个数!它就只有这么四个函数!
UiObject
1.clearTextField()
清除可编辑的输入框里的内容!
2.click()、clickAndWaitForNewWindow(long timeout)、clickAndWaitForNewWindow()、
clickBottomRight()、clickTopLeft()
点击元素操作!
3.exists()判断这个元素是否存在!
4.getChild(UiSelector selector)
查找匹配的子元素!
5.getChildCount()
获得子元素数量!
6.getContentDescription()、getText()
获得描述或者文本信息。
7.isCheckable()、isClickable()、isFocusable()、isLongClickable()、isScrollable()、
是否可以选中、点击、获得焦点、长按、滚动!
8.isChecked()、isEnabled()、isFocused()、isSelected()
是否已经打钩选中、控件是否可用、是否已经获得焦点以及是否选择了!
9.longClick()、longClickBottomRight()、longClickTopLeft()
长按操作!
10.setText(String text)
针对编辑框等,输入文字信息!但是,没法输入中文!我是这样的!
11.swipeDown(int steps)、swipeLeft(int steps)、swipeRight(int steps)、swipeUp(int steps)
滚动操作,分别对应竖屏与横屏!上下左右!
12.waitForExists(long timeout)
等待某个UI元素的出现!
13.waitUntilGone(long timeout)
等待某个UI元素消失!
UiScrollable
1.setAsHorizontalList()、setAsVerticalList()
设置滚动方向为垂直或水平
2.scrollTextIntoView(String text)
滚到某个要查找的元素
举例:- android自动化测试-UiAutomator常用类
- android uiautomator自动化测试
- UiAutomator android自动化测试
- Android-自动化测试UIAutomator
- Android自动化测试uiautomator
- Android UiAutoMator自动化测试
- Android Uiautomator 自动化测试
- Android Uiautomator 自动化测试
- Android自动化测试之UIAutomator
- Android自动化测试(UiAutomator)
- Android自动化测试工具uiautomator
- Python + Android + Uiautomator自动化测试
- Android自动化测试之UIAutomator
- Python + Android + Uiautomator自动化测试
- android uiautomator自动化测试记录
- Android自动化测试(UiAutomator)
- Android UiAutomator & UiAutomatorViewer 自动化测试
- Android自动化测试uiautomator入门
- QQ抢红包插件实现
- 页面超时跳转到登录页面被框架页面嵌套的问题
- Unable to execute dex: Multiple dex files define
- POJ3613 Cow Relays
- struts2 - modeldrive(模型驱动实例)
- android自动化测试-UiAutomator常用类
- hive导入数据到hbase 遇到的问题
- 双重检查锁定与延迟初始化
- mysql触发器 trigger
- bigdata——HBase+zookeeper+Hadoop集群构筑 之 zookeeper集群构筑
- LinuxC高级编程——线程
- Android保持屏幕常亮
- ASP.NET的OnClientClick与OnClick事件
- Oracle - 数据库的实例、表空间、用户、表之间关系