Appium LOG分析
启动Appium Server,并监听4723本地端口
[Appium] Welcome to Appium v1.10.0
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
Appium Client(测试脚本+Appium driver)向Appium server发送http请求创建一个seesion,在请求中Desired Capalities 为一个键值对的JSON格式
[HTTP] --> POST /wd/hub/session
[HTTP] {
"capabilities":{
"firstMatch":[{
"platformName":"android","appium:deviceName":"demo","appium:appPackage":"com.xueqiu.android","appium:appActivity":".view.WelcomeActivityAlias","appium:autoGrantPermissions":true}]},"desiredCapabilities":{
"platformName":"android","deviceName":"demo","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","autoGrantPermissions":true}}
[W3C] Calling AppiumDriver.createSession() with args: [{
"platformName":"android","deviceName":"demo","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","autoGrantPermissions":true},null,{
"firstMatch":[{
"platformName":"android","appium:deviceName":"demo","appium:appPackage":"com.xueqiu.android","appium:appActivity":".view.WelcomeActivityAlias","appium:autoGrantPermissions":true}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1552563283396 (19:34:43 GMT+0800 (中国标准时间))
Appium server收到请求后,创建一个session,此session id用于和appium client通讯
[Appium] Creating new AndroidDriver (v4.8.0) session
[Appium] Capabilities:
[Appium] platformName: android
[Appium] deviceName: demo
[Appium] appPackage: com.xueqiu.android
[Appium] appActivity: .view.WelcomeActivityAlias
[Appium] autoGrantPermissions: true
那这个session对象由谁创建的呢?最终由appium Driver来创建,appium driver与selenium driver有什么区别?
[BaseDriver] W3C capabilities {
"alwaysMatch":{
"platformNa... and MJSONWP desired capabilities {"platformName":"android","... were provided
[BaseDriver] Creating session with W3C capabilities: {
"alwaysMatch":{
"platformNa...
创建的session id
[BaseDriver] Session created with session id: 64490fd5-af8f-4483-adb3-8e45713108e3
[AndroidDriver] Java version is: 1.8.0_111
[AndroidDriver] Retrieving device list
adb命令是由谁发起的?appium server吗?
另这里尝试去查找Android的设备,并如果没有配置adb路径的话会尝试一直寻找adb.exe
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
检查到一个设备连接上,使用这个设备,如果在测试脚本中有设置设备的udid,则在logcat中会显示其设备的udid
[ADB] 1 device(s) connected
[AndroidDriver] Using device: 810EBM32R2VD
[ADB] Setting device id to 810EBM32R2VD
执行命令adb shell getprop ro.build.vesion.sdk获取Android的的sdk版本
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 22
[ADB] Device API level: 22
[AndroidDriver] App file was not listed, instead we're going to run com.xueqiu.android directly on the device
[AndroidDriver] Checking whether package is present on the device
执行命令adb shell pm list package获取Android设备上所安装的设备的包名,另:adb shell pm list packages com.xueqiu.android是否存在com.xueqiu.android的的设备
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell pm list packages com.xueqiu.android'
[AndroidDriver] Starting Android session
执行 adb wait-for-device等待设备处于连接的状态下再进行adb命令
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD wait-for-device'
检查设备是否能够正常响应adb命令,即通过adb shell echo ping,设备能够正常响应打印出"ping"则认为设备正常,这里响应有个超时时间(默认是5秒)
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell echo ping'
[AndroidDriver] Pushing settings apk to device...
执行命令adb shell dumpsys package io.appium.settings获取io.appium.setting是否已安装
[ADB] Getting install status for io.appium.settings
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell dumpsys package io.appium.settings'
[ADB] 'io.appium.settings' is installed
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell dumpsys package io.appium.settings'
[ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('2.11.0' >= '2.11.0')
[ADB] There is no need to install/upgrade 'C:\Program Files\Appium\resources\app\node_modules\io.appium.settings\apks\settings_apk-debug.apk'
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell ps'
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[ADB] Device API level: 22
执行adb shell setting put secure mock_location 1
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell settings put secure mock_location 1'
[Logcat] Starting logcat capture
获取设备的平台版本adb shell getprop ro.build.version.release
[ADB] Getting device platform version
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 5.1
获取屏幕尺寸大小adb shell wm size
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell wm size'
获取设备型号adb shell getprop ro.product.model
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell getprop ro.product.model'
[ADB] Current device property 'ro.product.model': m2 note
获取设备的厂商adb shell getprop ro.product.manufacturer
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell getprop ro.product.manufacturer'
[ADB] Current device property 'ro.product.manufacturer': Meizu
[AndroidDriver] No app sent in, not parsing package/activity
[AndroidDriver] No app capability. Assuming it is already on the device
检查设备是否安装了某个应用包
[ADB] Getting install status for com.xueqiu.android
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell dumpsys package com.xueqiu.android'
[ADB] 'com.xueqiu.android' is installed
强制停止某个应用adb shell am force-stop com.xueqiu.android
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell am force-stop com.xueqiu.android'
清理App的缓存adb shell pm clear
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell pm clear com.xueqiu.android'
[ADB] Device API level: 22
启动应用
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell dumpsys package com.xueqiu.android'
[AndroidDriver] Performed fast reset on the installed 'com.xueqiu.android' application (stop and clear)
[AndroidBootstrap] Watching for bootstrap disconnect
Bootsrap监听的接口为4724(appium server 到Android手机之间的端口),转发到PC上的4724端口
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD forward tcp\:4724 tcp\:4724'
启动UIAutomator
[UiAutomator] Starting UiAutomator
[UiAutomator] Moving to state 'starting'
[UiAutomator] Parsing uiautomator jar
[UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD push 'C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium-android-driver\\bootstrap\\bin\\AppiumBootstrap.jar' /data/local/tmp/'
[ADB] Attempting to kill all uiautomator processes
获取所有的进程
[ADB] Getting all processes with uiautomator
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell ps'
[ADB] No 'uiautomator' process has been found
启动UIAutomator,开启设备上的基于appiumbootstrap的socket服务
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s","810EBM32R2VD","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.xueqiu.android","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[UiAutomator] Moving to state 'online'
BootStrap的socket创建成功,并使用adb shell dumpsys window获取当前窗口的
[AndroidBootstrap] Android bootstrap socket is now connected
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell dumpsys window'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[AndroidDriver] Screen already unlocked, doing nothing
[ADB] Device API level: 22
启动测试应用,并为入口的Activity
[ADB] Running 'F:\Android\platform-tools\adb.exe -P 5037 -s 810EBM32R2VD shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S'
创建新的AndroidDriver的session,响应driver.createSession()请求创建session的请求
[Appium] New AndroidDriver session created successfully, session 64490fd5-af8f-4483-adb3-8e45713108e3 added to master session list
[BaseDriver] Event 'newSessionStarted' logged at 1552563308941 (19:35:08 GMT+0800 (中国标准时间))
[W3C (64490fd5)] Cached the protocol value 'W3C' for the new session 64490fd5-af8f-4483-adb3-8e45713108e3
[W3C (64490fd5)] Responding to client with driver.createSession() result: {
"capabilities":{
"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{
},"desired":{
"platformName":"android","deviceName":"demo","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","autoGrantPermissions":true},"platformName":"android","deviceName":"810EBM32R2VD","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","autoGrantPermissions":true,"deviceUDID":"810EBM32R2VD","platformVersion":"5.1","deviceScreenSize":"1080x1920","deviceModel":"m2 note","deviceManufacturer":"Meizu"}}
设置appium运行时的隐式等待时间
[HTTP] <-- POST /wd/hub/session 200 25546 ms - 729
[HTTP]
[HTTP] --> POST /wd/hub/session/64490fd5-af8f-4483-adb3-8e45713108e3/timeouts
[HTTP] {
"implicit":6000,"sessionId":"64490fd5-af8f-4483-adb3-8e45713108e3"}
AppiumDriver.timeouts()设置隐式等待时间6s
[W3C (64490fd5)] Calling AppiumDriver.timeouts() with args: [null,null,null,null,6000,"64490fd5-af8f-4483-adb3-8e45713108e3"]
[BaseDriver] W3C timeout argument: {
"implicit":6000}}
[BaseDriver] Set implicit wait to 6000ms
[W3C (64490fd5)] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /wd/hub/session/64490fd5-af8f-4483-adb3-8e45713108e3/timeouts 200 4 ms - 14
[HTTP]
设置元素查找方式
[HTTP] --> POST /wd/hub/session/64490fd5-af8f-4483-adb3-8e45713108e3/element
[HTTP] {
"using":"xpath","value":"//*[@text='自选' and contains(@resource-id, 'tab_name')]","sessionId":"64490fd5-af8f-4483-adb3-8e45713108e3"}
[W3C (64490fd5)] Calling AppiumDriver.findElement() with args: ["xpath","//*[@text='自选' and contains(@resource-id, 'tab_name')]","64490fd5-af8f-4483-adb3-8e45713108e3"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 6000 ms for condition
BootStrap发送命令给Android设备
[AndroidBootstrap] Sending command to android: {
"cmd":"action","action":"find","params":{
"strategy":"xpath","selector":"//*[@text='自选' and contains(@resource-id, 'tab_name')]","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {
"cmd":"action","action":"find","params":{
"strategy":"xpath","selector":"//*[@text='自选' and contains(@resource-id, 'tab_name')]","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG]