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 (三)执行过程的更多相关文章

  1. Action的三种实现方式,struts.xml配置的详细解释及其简单执行过程(二)

    勿以恶小而为之,勿以善小而不为--------------------------刘备 劝诸君,多行善事积福报,莫作恶 上一章简单介绍了Struts2的'两个蝴蝶飞,你好' (一),如果没有看过,请观 ...

  2. 精尽MyBatis源码分析 - SQL执行过程(三)之 ResultSetHandler

    该系列文档是本人在学习 Mybatis 的源码过程中总结下来的,可能对读者不太友好,请结合我的源码注释(Mybatis源码分析 GitHub 地址.Mybatis-Spring 源码分析 GitHub ...

  3. ASP.NET Web API 过滤器创建、执行过程(二)

    ASP.NET Web API 过滤器创建.执行过程(二) 前言 前面一篇中讲解了过滤器执行之前的创建,通过实现IFilterProvider注册到当前的HttpConfiguration里的服务容器 ...

  4. ASP.NET Web API 过滤器创建、执行过程(一)

    ASP.NET Web API 过滤器创建.执行过程(一) 前言 在上一篇中我们讲到控制器的执行过程系列,这个系列要搁置一段时间了,因为在控制器执行的过程中包含的信息都是要单独的用一个系列来描述的,就 ...

  5. 通过源码了解ASP.NET MVC 几种Filter的执行过程

    一.前言 之前也阅读过MVC的源码,并了解过各个模块的运行原理和执行过程,但都没有形成文章(所以也忘得特别快),总感觉分析源码是大神的工作,而且很多人觉得平时根本不需要知道这些,会用就行了.其实阅读源 ...

  6. Hadoop MapReduce执行过程详解(带hadoop例子)

    https://my.oschina.net/itblog/blog/275294 摘要: 本文通过一个例子,详细介绍Hadoop 的 MapReduce过程. 分析MapReduce执行过程 Map ...

  7. 高程(4):执行环境、作用域、上下文执行过程、垃圾收集、try...catch...

    高程三 4.2.4.3 一.执行环境 1.全局执行环境是最外层的执行环境. 2.每个函数都有自己的执行环境,执行函数时,函数环境就会被推入一个当前环境栈中,执行完毕,栈将其环境弹出,把控制器返回给之前 ...

  8. Web APi之过滤器执行过程原理解析【二】(十一)

    前言 上一节我们详细讲解了过滤器的创建过程以及粗略的介绍了五种过滤器,用此五种过滤器对实现对执行Action方法各个时期的拦截非常重要.这一节我们简单将讲述在Action方法上.控制器上.全局上以及授 ...

  9. JS的解析与执行过程

    JS的解析与执行过程 全局中的解析和执行过程 预处理:创建一个词法环境(LexicalEnvironment,在后面简写为LE),扫描JS中的用声明的方式声明的函数,用var定义的变量并将它们加到预处 ...

随机推荐

  1. 查看详细linux系统信息的命令和方法

    查看内存大小: cat /proc/meminfo |grep MemTotaluname -a # 查看内核/操作系统/CPU信息的linux系统信息命令head -n 1 /etc/issue # ...

  2. 小程序scroll-view采坑

    scroll-view分为水平滚动和垂直滚动.注意滚动视图垂直滚动时一定要设置高度否则的话scroll-view不会生效.

  3. 001 开发环境搭建、安卓项目结构、R文件位置、asset目录创建

    1.安卓开发平台搭建 (1)下载SDK基础工具包(自己的百度云中) (2)将下载的安装包(android-sdk_r24.4.1-windows.zip)解压后,放到以下路径 C:\SoftAppli ...

  4. 项目中遇到的问题:前台 disabled 与 后台disabled

    TPRI项目流程,点[保存],“人员”服务器端控件,如果在前台disabled设置,则值会丢失:在后台设置disabled就可以.

  5. P2421 [NOI2002]荒岛野人

    传送门 答案不大于 $10^6$,考虑枚举答案 对于枚举的 ans,必须满足对于任意 i,j(i≠j) 都有 使式子$c_i+kp_i \equiv c_j+kp_j\ (mod\ ans)$成立的最 ...

  6. 10-排序5 PAT Judge (25 分)

    The ranklist of PAT is generated from the status list, which shows the scores of the submissions. Th ...

  7. NAS与SAN RAID

    存储区域网络 SAN 存储区域网络(Storage Area Network,简称SAN)采用网状通道(Fibre Channel ,简称FC,区别与Fiber Channel光纤通道)技术,通过FC ...

  8. 5.SpringMVC

    1.SpringMVC概述 概述: SpringMVC是基于请求驱动,围绕一个核心Servlet 转发请求到对应的Controller而设计的优点:是一个典型的教科书式的MVC构架,易学易用提供了清晰 ...

  9. 虚拟机 --- windows传输文件到虚拟机内

    安装xftp 如果未安装的,可以点击上图红框的图标,会有链接....下载时记得选择school那一个身份,这是免费的...邮箱必须要写,因为下载链接会发送到你的邮箱里,如果没收到就换一个邮箱 下载完后 ...

  10. SpringMVC中的视图和视图解析器

    对于控制器的目标方法,无论其返回值是String.View.ModelMap或是ModelAndView,SpringMVC都会在内部将它们封装为一个ModelAndView对象进行返回.  Spri ...