uiautomator

元素定位方法之Uiautomator方法

假如想象 提交于 2019-12-04 11:29:36
这个方法只能用于安卓系统,方法通过类UiSelector()来构造对象的 官网地址: https://developer.android.google.cn/topic/libraries/testing-support-library/index.html#UIAutomator 打开链接到 UiSelector 类 https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html 定位方法:driver.find_element_by_android_uiautomator( 'new UiSelector().text("9")') 返回元素对象 通过元素文本进行定位: 1、根据文本定位   text(String text)   new UiSelector().text("9") 2、模糊匹配文本   textContains(文本) 3、以某个文本开头来匹配   textStartsWith(文本) 4、正则匹配   textMatches(正则表达式)    new UiSelector().textMatches("^D.*" ) 根据 resourceId 定位元素:   resourceId(id)   new UiSelector()

android uiautomator runtest error didn't find class

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: recent i tryied getting started with android uiautomation testing. The tutorial from the developer site I've worked through a few times and after having some problems and solving them now I have got a bigger issue. I created a project, imported the two jar files and builded a java testcase scenario (the one from the tutorial.) after that I created an uitest projekt with shell command line. updated the build.xml created a jar file and pushed it onto my device. As far as good everything worked nicely upon this point. But tryin to run my tests

Android Testing: UIAutomator vs Espresso

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I was seeking for test frameworks for Android UI automation and I stumbled upon UI Automator and Espresso and this is the part I am confused about - Both are maintained by Google Both are used for functional UI testing Both are Android only frameworks So my questions/doubts here are - What is the major difference between UI Automator and Espresso ? Will the source code have to be modified to integrate any of these frameworks? Does one framework hold any advantage over the other? If yes, then which framework is the most suitable for UI

基于appium的常用元素定位方法

瘦欲@ 提交于 2019-12-03 00:28:45
一、元素定位工具   app应用的元素使用的是控件定位,不同于web网页,web网页定位元素通常使用的是F12工具,那么在app当中我们则要借助其它的工具来辅助定位。 1.uiautomatorviewer.bat   uiautomatorviewer.bat工具在安装完ADT工具之后,位于ADT安装路径的android-sdk-windows\tools\bin目录下      双击启动即可,启动之后,在初始界面上,点击如图位置按钮可以进行截屏      截屏后即可查看各个元素,截屏后的效果:    2.appium检查器   在appium启动后的日志窗口界面,点击“启动检查器会话”,会跳转到检查器启动参数配置界面,参数配置直接将我们代码里面的启动参数搬过来就可以了。         点击启动后,会根据我们配置的应用信息,自动跳转到应用的主页面,我们就可以开始进行元素定位了:    二、常用元素定位方法   appium从selenium中继承了所有的元素定位方法,并且增加了自己的一些方法,我们先看看appium的源码:      但是从继承selenium中的定位方法中,一般只会用到id、class_name、xpath这三种方法,总结起来,appium中常用的定位方法一般有以下五种: 通过id定位:resource-id 通过class_name定位:class

Android 模拟手工点点点的Uiautomator初步使用(一)

匿名 (未验证) 提交于 2019-12-03 00:26:01
1、首先建立Android工程 2、在工程的build.gradle(Modul:app)中添加依赖 3、注意下gradle的版本和对应appcompat-v 的版本要相对应,不然这里有可能报错 4、写简单的代码: import android.app.Instrumentation; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.runner.AndroidJUnit4; import android.support.test.uiautomator.By; import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.Until; import android.util.Log; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner

appium工作流程解析

匿名 (未验证) 提交于 2019-12-02 23:47:01
Ios9.3以前使用的是UIAutomation,Ios9.3以后使用XCUITest。如果只使用Apple的UIAutomation测试框架,我们只能用javascript来编写测试用例,而且只能用Instruction来运行测试用例。 Android4.0以下使用基于Android Instrumentation框架实现的Selendroid,Android4.0以上使用UIAutomator。同样,如果只使用Google的UIAutomation,我们就只能用java来编写测试用例 Appium是在手机操作系统自带的测试框架基础上实现的,而且它支持Selenium WebDriver支持的所有语言,如java、Object-C、JavaScript、Php、Python、Ruby、C#、Clojure,或者Perl语言,更可以使用Selenium WebDriver的Api,实现了真正的跨平台自动化测试 客户端发送testcase脚本――> appium server通过PC端4723端口监听 ――> 解析脚本参数给PC端4724端口 ――> 发送给移动设备4724端口 ――> Bootstrap.jar开启socket服务,监听移动设备4724端口 ――> Bootstrap.jar把命令发给uiautomator ――> uiautomator执行命令,并返回执行结果

UIAutomator、Robotium、Appium对比

匿名 (未验证) 提交于 2019-12-02 23:38:02
一、原理 1.UiAutomator――基于UIAutomation的用户界面自动化测试框架,可以跨应用工作,谷歌亲生的。 UIAutomation在Android4.3发布时有了新版本,官方简介: http://blog.csdn.net/zhubaitian/article/details/40504827。 Android4.3之前:使用inputManager或者更早的WindowsManager来注入KeyEvent Android4.3之后:使用Accessibility APIs来注入事件。(AccessibilityService本来是做一些辅助功能的,提供了一系列的事件回调,帮助我们指示一些用户及界面的状态变化,主要给残障人群提供帮助。) 2.Robotium――基于Instrumentation开发出来的一套测试框架 Instrumentation的官方简介: http://blog.csdn.net/zhubaitian/article/details/39578915 Instrumentation可以把测试包和目标测试应用加载到同一个进程中进行。既然各个控件和测试代码都运行在同一个进程中了,测试代码当然就可以调用这些控件的方法了,同时修改和验证这些控件的一些项就不在话下了。 Instrumentation的运行原理

uiautomator2 使用Python测试 Android应用

匿名 (未验证) 提交于 2019-12-02 22:51:30
uiautomator2 使用Python测试 Android应用 2018-03-01 09:33 by 虫师, 4575 阅读, 2 评论, 收藏 , 编辑 GitHub地址: https://github.com/openatx/uiautomator2 介绍 uiautomator2 是一个可以使用Python对Android设备进行UI自动化的库。其底层基于Google uiautomator,Google提供的uiautomator库可以获取屏幕上任意一个APP的任意一个控件属性,并对其进行任意操作,但有两个缺点: 1、测试脚本只能使用Java语言。 2、测试脚本必须每次被上传到设备上运行。 我们希望测试能够用一个更脚本化的语言,例如Python编写,同时可以每次所见即所得地修改测试、运行测试。 安装 安装uiautomator2 pip install --pre uiautomator2 pip install pillow 初始化 部署相关的守护进程。 电脑连接上一个手机或多个手机, 确保adb已经添加到环境变量中,执行下面的命令会自动安装本库所需要的设备端程序:uiautomator-server 、atx-agent、openstf/minicap、openstf/minitouch python -m uiautomator2 init 安装完成

万物有源_Appium框架原理浅析

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 17:08:08
其实我觉得Appium的Log已经格外人性化了,直接看debugLog,就可以了解流程和原理了。 一、安卓平台图解 二、原理 Appium是由Nodejs编写的,集成了现有优秀框架,以Selenium WebDriver的协议统一起来,遵循RESTful设计风格web服务器, 它接受客户端的连接,接收客户端的命令,在手机设备上执行命令,然后通过HTTP的响应收集命令执行的结果。 (1)最上面的Client端可以是多种语言编写,它类似于selenium webdriver,封装了selenium的API,并添加了部分的新的API,我们可以依据这些API编辑自动化脚本。 (2)Json Wire Protocol是一种协议,遵循REST风格,以JSON方法进行传输,是一系列的键值对,遵循W3C WebDriver Spec设计风格。 (3)中间是起的Appium的服务,Appium在这边起了一个Server(4723端口),在这里提供了一套web服务,Appium Server接收web driver标准请求,解析请求内容,调⽤用对应的uiautomator响应操作。 (4)Appium server可以把请求接收并转义转发给中间件Bootstrap.jar,它是用java写的,安装在手机上。Bootstrap 接收appium 的命令(4724端口),最终通过调

万物有源_Android自动化测试框架UIAutomator原理浅析

♀尐吖头ヾ 提交于 2019-12-01 08:57:47
简介 UIAutomator是一个Android自动化测试框架,是谷歌在Android4.1版本发布时推出的一款用Java编写的UI测试框架,它只能用于UI即黑盒方面的测试。所以UIAutomator只能运行在Android4.1之后的版本,其最大的特点是可以跨进程操作。我们可以使用UIAutomator框架提供的一些方便的API来对Android应用进行一系列的自动化测试操作,如点击、滑动、键盘输入、长按以及常用的断言方法。可以代替繁复的手工测试。 优点: Google自家推出,其稳定性和后续的维护更新可以得到保障,运行也有更多的权限。 可以跨进程操作,这点比起其他基于instrumention框架的自动化工具如Robotium是无法直接做到的。 运行速度快。 缺点: 不支持Android4.1以下的版本。 不支持Webview,所以一般无法对浏览器应用进行测试。 原理 首先,Google的UIAutomator参考微软的UIAutomation提供的一套用在Android上的自动化测试框架。 基于Android AccessilibilityService。 在这里简单介绍一下:AccessilibilityService是一个可访问服务,它是一个为增强用户界面并帮助残疾用户的应用程序,或者用户可能无法完全与设备交互。举个简单的例子,假如一个用户在开车