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. Qt 学习之路 2(10):对象模型

    Home / Qt 学习之路 2 / Qt 学习之路 2(10):对象模型 Qt 学习之路 2(10):对象模型  豆子  2012年9月2日  Qt 学习之路 2  45条评论 标准 C++ 对象模 ...

  2. vue项目中禁止移动端双击放大,双手拉大放大的方法

    在vue打包后生成的dist目录文件下下面有index.html 打开里面 把原来的这个 <meta name=viewport content="width=device-width ...

  3. IE浏览器提示对象不支持“append”属性或方法

    如下代码在IE浏览器中无法执行,提示对象不支持“append”属性或方法 var tImg = document.createElement("img"); tImg.setAtt ...

  4. 2016计蒜之道初赛第四场A

    在每年的淘宝“双十一”时,访问量都会暴涨,服务器的请求会被流量分配程序按照一定策略,分发给不同的进程去处理.有一类请求,有两个进程可以接受分发的请求,其中一个进程所在服务器的配置.网络传输性能等都要优 ...

  5. python 文件与异常

    ####文件### r: -只能读 不能写 -读取文件不存在,是会报错 r+: - 可以执行读写操作; - 文件不存在, 报错: w: -只能写,不能读 -会清空文件内容 -文件不存在,会新建文件 w ...

  6. sqlserver 索引进阶(上)

    参考原文:http://www.cnblogs.com/tjy9999/p/4494662.html 2. 非聚集索引 SET STATISTICS io ON SET STATISTICS time ...

  7. 8.JSP基础

    1.Servlet与JSP关系 JSP工作原理: 一个JSP文件第一次被请求时,JSP引擎把该JSP文件转换成为一个servlet JSP引擎使用javac把转换成的servlet的源文件编译成相应的 ...

  8. 关于element-ui表格样式设置的方法cell-class-name

    关于element-ui表格使用的一些方法 最近在用Vue.js和elment-ui做一个后台管理项目,不得不说element功能非常强大,提供了许多组件,基本可以满足一些基础的开发了.因为我做的后台 ...

  9. 爬虫(POST)——有道翻译(有bug)

    工具:python3 过程:抓包得到有道翻页面的url:复制post请求头,得到headers中的信息:复制post请求的body,得到formdata中的信息.构造post请求,返回响应 impor ...

  10. Silverlight TreeView 带 checkbox和图片

    前段时间做Silverlight TreeView 控件,但是要带checkbox和图片,在网上到处找相关的例子,效果图如下 xaml代码 <UserControl x:Class=" ...