appium (三)执行过程
appium界面运行过程:
1、启动一个http服务器:127.0.0.1:4723
2、根据测试代码setUp()进行初始化,在http服务器上建立一个session对象
3、开始调用adb,找到连接上的设备,设置设备id
4、等待设备准备好响应命令
5、开启logcat日志监控
6、将生成的apk属性信息文件strings.json存到了设备 /data/local/tmp目录下
7、读取apk安装情况
8、端口映射,发给appium httpserver的内容,经过httpserver后直接发给设备
forward tcp:4724 tcp:4724
9、将AppiumBootstrap.jar包存到设备的 /data/local/tmp目录下
10、安装UnicodeIME-debug.apk到设备上
11、安装settings_apk-debug.apk到设备上
12、安装unlock_apk-debug.apk到设备上
13、 kill所有的uiautomator进程
14、运行bootstrap---uiautomator runtest ***.jar –c ……-e…..
15、在端口4724打开appium socket server
16、加载json,唤醒客户端
17、提交command到appium
18、启动设备,解锁屏幕,准备接收command
19、将响应结果返回给client
20、执行测试代码
21、关闭日志监控
22、关闭客户端链接
23、关闭Uiautomation
24、清理Android对象
25、清理appium session
> Launching Appium server with command: C:\Program Files (x86)\Appium\node.exe lib\server\main.js --address 127.0.0.1 --port 4723 --platform-name android --platform-version 21 --automation-name Appium --log-no-color
> info: Welcome to Appium v1.4.16 (REV ae6877eff263066b26328d457bd285c0cc62430d)
> info: Appium REST http interface listener started on 127.0.0.1:4723
> info: [debug] Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"21","automationName":"Appium"}
> info: Console LogLevel: debug
以上是在PC端启动一个http服务:127.0.0.1:4723
> info: --> POST /wd/hub/session {"requiredCapabilities":{},"desiredCapabilities":{"platformVersion":"5.1.2","deviceName":"MI 3","platformName":"Android","appActivity":"com.moer.moerfinance.advertisement.AdvertisementActivity","appPackage":"com.moer.moerfinance"}}
> info: Client User-Agent string: Python-urllib/2.7
> info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
> info: [debug] Creating new appium session f5f2cd10-5cac-415b-9464-d54a15c8e693
根据setUp()进行初始化(desired_caps里面的参数设置信息),在http服务器上建立一个session对象
> info: Starting android appium
> info: [debug] Getting Java version
> info: Java version is: 1.7.0_79
开启Android的appium服务,检查当前的java版本
> info: [debug] Checking whether adb is present
> info: [debug] Using adb from C:\Android\sdk\platform-tools\adb.exe
> warn: No app capability, can't parse package/activity
> info: [debug] Using fast reset? true
> info: [debug] Preparing device for session
> info: [debug] Not checking whether app is present since we are assuming it's already on the device
> info: Retrieving device
> info: [debug] Trying to find a connected android device
> info: [debug] Getting connected devices...
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe devices
> info: [debug] 1 device(s) connected
> info: Found device d643f50
开启adb,获取已经连接的设备,获取设备的id
> info: [debug] Setting device id to d643f50
设置设备的id
> info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 wait-for-device
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "echo 'ready'"
等待设备准备好响应命令,通过adb命令在设备上执行一个echo,验证设备是否准备好
> info: [debug] Starting logcat capture
> info: [debug] Getting device API level
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 18
> info: Device API level is: 18
> info: [debug] Extracting strings for language: default
> info: [debug] Apk doesn't exist locally
> info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
开启logcat日志监控
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "rm -rf /data/local/tmp/strings.json"
删除手机/data/local/tmp/strings.json文件,将生成的apk属性信息文件strings.json存放到/data/local/tmp/临时目录下
> info: [debug] Not uninstalling app since server not started with --full-reset
> info: [debug] Skipping install since we launched with a package instead of an app path
读取apk安装情况,判断是否需要安装应用,因为应用已经安装过,并没有提供应用的存放路径,所以跳过安装的步骤
> info: [debug] Forwarding system:4724 to device:4724
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 forward tcp:4724 tcp:4724
端口映射,这个命令也是通过adb的命令实现的,具体是将发送给appium http server的命令经过端口映射直接发送给设备
> info: [debug] Pushing appium bootstrap to device...
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 push "C:\\Program Files (x86)\\Appium\\node_modules\\appium\\build\\android_bootstrap\\AppiumBootstrap.jar" /data/local/tmp/
将包AppiumBootstrap.jar存放到设备的/data/local/tmp/目录下
> info: [debug] Pushing settings apk to device...
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
将settings_apk-debug.apk安装到手机设备上,这个应用是一个服务
> info: [debug] Pushing unlock helper app to device...
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
将unlock_apk-debug.apk安装到手机设备,这个应用主要是用于解锁设备屏幕
> info: Starting App
> info: [debug] Attempting to kill all 'uiautomator' processes
将设备上的所有uiautomator进程都kill掉
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "ps 'uiautomator'"
> info: [debug] No matching processes found
查看设备上所有的uiautomator进程
> info: [debug] Running bootstrap
> info: [debug] spawning: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.moer.moerfinance -e disableAndroidWatchers false
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class="io".appium.android.bootstrap.Bootstrap
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
运行bootstrap---uiautomator runtest ***.jar –c ……-e…..
> info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
> info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
在端口4724打开appium socket server
> info: [debug] [BOOTSTRAP] [debug] Loading json...
> info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
> info: [debug] Waking up device if it's not alive
加载json,唤醒客户端
> info: [debug] Pushing command to appium work queue: ["wake",{}]
> info: [debug] [BOOTSTRAP] [debug] Client connected
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: wake
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
提交command到appium
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "dumpsys window"
> info: [debug] Screen already unlocked, continuing.
启动设备,解锁屏幕,准备接受命令
> info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":false,"status":0}
将执行响应结果返回给client
> info: [debug] Getting device API level
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 18
获取sdk的一些信息
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.moer.moerfinance/com.moer.moerfinance.advertisement.AdvertisementActivity"
> info: [debug] Waiting for pkg "com.moer.moerfinance" and activity "com.moer.moerfinance.advertisement.AdvertisementActivity" to be focused
> info: [debug] Getting focused package and activity
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "dumpsys window windows"
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "getprop ro.build.version.release"
> info: [debug] Device is at release version 4.3
> info: [debug] Device launched! Ready for commands
> info: [debug] Setting command timeout to the default of 60 secs
> info: [debug] Appium session started with sessionId f5f2cd10-5cac-415b-9464-d54a15c8e693
> info: <-- POST /wd/hub/session 303 6908.432 ms - 74
> info: --> GET /wd/hub/session/f5f2cd10-5cac-415b-9464-d54a15c8e693 {}
> info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.3","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"5.1.2","deviceName":"MI 3","platformName":"Android","appActivity":"com.moer.moerfinance.advertisement.AdvertisementActivity","appPackage":"com.moer.moerfinance"},"deviceName":"d643f50","platformName":"Android","appActivity":"com.moer.moerfinance.advertisement.AdvertisementActivity","appPackage":"com.moer.moerfinance"},"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693"}
> info: <-- GET /wd/hub/session/f5f2cd10-5cac-415b-9464-d54a15c8e693 200 13.851 ms - 664 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.3","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformVersion":"5.1.2","deviceName":"MI 3","platformName":"Android","appActivity":"com.moer.moerfinance.advertisement.AdvertisementActivity","appPackage":"com.moer.moerfinance"},"deviceName":"d643f50","platformName":"Android","appActivity":"com.moer.moerfinance.advertisement.AdvertisementActivity","appPackage":"com.moer.moerfinance"},"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693"}
> info: --> POST /wd/hub/session/f5f2cd10-5cac-415b-9464-d54a15c8e693/appium/app/reset {"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693"}
> info: [debug] Resetting app mid-session
> info: [debug] Running device specific reset
> info: [debug] Running fast reset (stop and clear)
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "am force-stop com.moer.moerfinance"
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "pm clear com.moer.moerfinance"
> info: [debug] Waiting for pkg "com.moer.moerfinance" and activity "com.moer.moerfinance.advertisement.AdvertisementActivity" to not be focused
> info: [debug] Getting focused package and activity
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "dumpsys window windows"
> info: [debug] Getting device API level
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "getprop ro.build.version.sdk"
> info: [debug] Device is at API Level 18
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.moer.moerfinance/com.moer.moerfinance.advertisement.AdvertisementActivity"
> info: [debug] Waiting for pkg "com.moer.moerfinance" and activity "com.moer.moerfinance.advertisement.AdvertisementActivity" to be focused
> info: [debug] Getting focused package and activity
启动服务,准备接收执行测试用例
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "dumpsys window windows"
> info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693"}
> info: <-- POST /wd/hub/session/f5f2cd10-5cac-415b-9464-d54a15c8e693/appium/app/reset 200 2537.883 ms - 76 {"status":0,"value":null,"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693"}
> info: --> POST /wd/hub/session/f5f2cd10-5cac-415b-9464-d54a15c8e693/touch/perform {"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693","actions":[{"action":"press","options":{"y":800,"x":800}},{"action":"wait","options":{"ms":500}},{"action":"moveTo","options":{"y":800,"x":200}},{"action":"release","options":{}}]}
> info: [debug] Pushing command to appium work queue: ["swipe",{"startX":800,"startY":800,"endX":200,"endY":800,"steps":14}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"swipe","params":{"startX":800,"startY":800,"endX":200,"endY":800,"steps":14}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: swipe
> info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1080,1920]
> info: [debug] [BOOTSTRAP] [debug] Display bounds: [0,0][1080,1920]
> info: [debug] [BOOTSTRAP] [debug] Swiping from [x=800.0, y=800.0] to [x=200.0, y=800.0] with steps: 14
执行测试用例结束
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
> info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693"}
返回客户端执行的结果
> info: <-- POST /wd/hub/session/f5f2cd10-5cac-415b-9464-d54a15c8e693/touch/perform 200 275.518 ms - 76 {"status":0,"value":true,"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693"}
> info: --> DELETE /wd/hub/session/f5f2cd10-5cac-415b-9464-d54a15c8e693 {}
> info: Shutting down appium session
关闭会话服务
> info: [debug] Pressing the HOME button
> info: [debug] executing cmd: C:\Android\sdk\platform-tools\adb.exe -s d643f50 shell "input keyevent 3"
回到设备HOME
> info: [debug] Stopping logcat capture
> info: [debug] Logcat terminated with code null, signal SIGTERM
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"}
> info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"OK, shutting down","status":0}
关闭日志监控
> info: [debug] [BOOTSTRAP] [debug] Closed client connection
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class="io".appium.android.bootstrap.Bootstrap
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
> info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
> info: [debug] [UIAUTOMATOR STDOUT] Time: 9.904
> info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
> info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
> info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
> info: [debug] UiAutomator shut down normally
关闭UiAutomation
> info: [debug] Cleaning up android objects
清理Android对象
> info: [debug] Cleaning up appium session
> info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693"}
> info: <-- DELETE /wd/hub/session/f5f2cd10-5cac-415b-9464-d54a15c8e693 200 704.079 ms - 76 {"status":0,"value":null,"sessionId":"f5f2cd10-5cac-415b-9464-d54a15c8e693"}
清理appium session
appium (三)执行过程的更多相关文章
- Action的三种实现方式,struts.xml配置的详细解释及其简单执行过程(二)
勿以恶小而为之,勿以善小而不为--------------------------刘备 劝诸君,多行善事积福报,莫作恶 上一章简单介绍了Struts2的'两个蝴蝶飞,你好' (一),如果没有看过,请观 ...
- 精尽MyBatis源码分析 - SQL执行过程(三)之 ResultSetHandler
该系列文档是本人在学习 Mybatis 的源码过程中总结下来的,可能对读者不太友好,请结合我的源码注释(Mybatis源码分析 GitHub 地址.Mybatis-Spring 源码分析 GitHub ...
- ASP.NET Web API 过滤器创建、执行过程(二)
ASP.NET Web API 过滤器创建.执行过程(二) 前言 前面一篇中讲解了过滤器执行之前的创建,通过实现IFilterProvider注册到当前的HttpConfiguration里的服务容器 ...
- ASP.NET Web API 过滤器创建、执行过程(一)
ASP.NET Web API 过滤器创建.执行过程(一) 前言 在上一篇中我们讲到控制器的执行过程系列,这个系列要搁置一段时间了,因为在控制器执行的过程中包含的信息都是要单独的用一个系列来描述的,就 ...
- 通过源码了解ASP.NET MVC 几种Filter的执行过程
一.前言 之前也阅读过MVC的源码,并了解过各个模块的运行原理和执行过程,但都没有形成文章(所以也忘得特别快),总感觉分析源码是大神的工作,而且很多人觉得平时根本不需要知道这些,会用就行了.其实阅读源 ...
- Hadoop MapReduce执行过程详解(带hadoop例子)
https://my.oschina.net/itblog/blog/275294 摘要: 本文通过一个例子,详细介绍Hadoop 的 MapReduce过程. 分析MapReduce执行过程 Map ...
- 高程(4):执行环境、作用域、上下文执行过程、垃圾收集、try...catch...
高程三 4.2.4.3 一.执行环境 1.全局执行环境是最外层的执行环境. 2.每个函数都有自己的执行环境,执行函数时,函数环境就会被推入一个当前环境栈中,执行完毕,栈将其环境弹出,把控制器返回给之前 ...
- Web APi之过滤器执行过程原理解析【二】(十一)
前言 上一节我们详细讲解了过滤器的创建过程以及粗略的介绍了五种过滤器,用此五种过滤器对实现对执行Action方法各个时期的拦截非常重要.这一节我们简单将讲述在Action方法上.控制器上.全局上以及授 ...
- JS的解析与执行过程
JS的解析与执行过程 全局中的解析和执行过程 预处理:创建一个词法环境(LexicalEnvironment,在后面简写为LE),扫描JS中的用声明的方式声明的函数,用var定义的变量并将它们加到预处 ...
随机推荐
- mybatis组合实体查询
mybatis组合实体查询 <resultMap id="wxIndexMap" type="com.o2o.common.model.wxuntity.WxInd ...
- vue四、实例
1.new Vue创建根实例 2.data对象,所有的属性加入到 Vue 响应式系统-值发生改变时,视图自动变更为新值 只有实例被创建时存在的属性才会响应式改变,后增加的不会 vue定义的实例属性和方 ...
- IE下 checkbox、radio等标签的label中的img点击无效(点击不能选中)问题解决
类似以下代码,点击图片不能选中checkbox <input id="dw_1" name="shape[]" value="Round&quo ...
- spring boot 加载配置 文件
在springboot启动的过程中,默契情况下会在classpath路径下加载application.properties当做系统配置文件,但有时候我们想要替换成另一个文件,可以 通过以下方式: ...
- vue学习—组件的定义注册
组件的定义注册 效果: 方法一: <div id="box"> <v-header></v-header> <hr /> <b ...
- windows server 2003和window2008区别
windows 2003与windows 2008简介 windows 2003是微软老一代的服务器系统,自带iis 6,操作界面类似于windows XP,因为国内很多IDC都喜欢用盗版window ...
- springMVC从前端接受boolean类型的属性失败的问题
springMVC从前端接收到的实体又一个boolean类型的属性,发现不管前端怎么操作,后台接收到的值都是false. 问题出现原因: eclipse在给实体属性生成getter和setter的时候 ...
- vue懒加载 路由 router 的编写(resolve)
如果用import引入的话,当项目打包时路由里的所有component都会打包在一个js中,造成进入首页时,需要加载的内容过多,时间相对比较长.当你用require这种方式引入的时候,会将你的comp ...
- ES6结构赋值
解构赋值 从ES6开始,JavaScript引入了解构赋值,可以同时对一组变量进行赋值. 什么是解构赋值?我们先看看传统的做法,如何把一个数组的元素分别赋值给几个变量: var array = ['h ...
- python 16 进程和线程
进程和线程 很多同学都听说过,现代操作系统比如Mac OS X,UNIX,Linux,Windows等,都是支持“多任务”的操作系统. 什么叫“多任务”呢?简单地说,就是操作系统可以同时运行多个任务. ...