Appium Appium log 分析

龙修 · 2018年06月12日 · 825 次阅读

1、启动 Appium,监听本地 4723 端口

[info] [Appium] Welcome to Appium v1.8.0
[info] [Appium] Appium REST http interface listener started on 0.0.0.0:4723

2、连通测试
[info] [HTTP] --> GET /wd/hub/sessions

[info] [HTTP] {}

[debug] [MJSONWP] Calling AppiumDriver.getSessions() with args: []
[debug] [MJSONWP] Responding to client with driver.getSessions() result: []
[info] [HTTP] <-- GET /wd/hub/sessions 200 5 ms - 40

3、post 本地测试代码到服务器

[info] [HTTP]

[info] [HTTP] --> POST /wd/hub/session

[info] [HTTP] {"desiredCapabilities":{"appActivity":".view.WelcomeActivityAlias","appPackage":"com.xueqiu.android","deviceName":"ddd","platformName":"android","newCommandTimeout":0,"connectHardwareKeyboard":true}}

[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":".view.WelcomeActivityAlias","appPackage":"com.xueqiu.android","deviceName":"ddd","platformName":"android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]

4、新建 sessionID

[debug] [BaseDriver] Event 'newSessionRequested' logged at 1528772753693 (11:05:53 GMT+0800 (中国标准时间))
[info] [Appium] Creating new AndroidDriver (v2.6.0) session
[info] [Appium] Capabilities:
[info] [Appium] appActivity: .view.WelcomeActivityAlias
[info] [Appium] appPackage: com.xueqiu.android
[info] [Appium] deviceName: ddd
[info] [Appium] platformName: android
[info] [Appium] newCommandTimeout: 0
[info] [Appium] connectHardwareKeyboard: true
[debug] [BaseDriver] Creating session with MJSONWP desired capabilities: {"appActivity":".view.Welco...
[warn] [BaseDriver] The following capabilities were provided, but are not recognized by appium: connectHardwareKeyboard.
[info] [BaseDriver] Session created with session id: 38ca78f8-4b34-4b0d-90b7-5b3c59014559

5、获取系统信息
检查 Java 版本
检查 ANDROID_HOME
检查 adb

[debug] [AndroidDriver] Getting Java version
[info] [AndroidDriver] Java version is: 1.8.0_141
[info] [ADB] Checking whether adb is present
[warn] [ADB] The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb.
[info] [ADB] Using adb from D:\Program\Android Studio\SDK\platform-tools\adb.exe
[info] [ADB]

6、获取当前连接设备列表,并连接

[info] [AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[info] [AndroidDriver] Using device: 192.168.91.101:5555
[info] [ADB] Checking whether adb is present
[warn] [ADB] The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb.
[info] [ADB] Using adb from D:\Program\Android Studio\SDK\platform-tools\adb.exe
[info] [ADB]
[debug] [ADB] Setting device id to 192.168.91.101:5555

7、检查 app 是否存在设备上

[info] [AndroidDriver] App file was not listed, instead we're going to run com.xueqiu.android directly on the device
[debug] [AndroidDriver] Checking whether package is present on the device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell pm list packages com.xueqiu.android'

8、检查设备能否正常响应(ping)

[info] [AndroidDriver] Starting Android session
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 wait-for-device'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell echo ping'

9、安装 io.appium.settings 到手机并启动

[debug] [AndroidDriver] Pushing settings apk to device...
[debug] [ADB] Getting install status for io.appium.settings
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell pm list packages io.appium.settings'
[debug] [ADB] App is installed
[debug] [ADB] Getting package info for 'io.appium.settings'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell dumpsys package io.appium.settings'
[info] [ADB] Checking whether aapt is present
[warn] [ADB] The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for aapt.
[info] [ADB] Using aapt from D:\Program\Android Studio\SDK\build-tools\27.0.3\aapt.exe
[info] [ADB]

[debug] [ADB] The installed 'io.appium.settings' package does not require upgrade ('2.3.0' >= '2.3.0')
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell ps'
[debug] [AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell getprop ro.build.version.sdk'
[debug] [ADB] Current device property 'ro.build.version.sdk': 23
[debug] [ADB] Device API level: 23
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell appops set io.appium.settings android:mock_location allow'
[warn] [AndroidDriver] setDeviceLanguageCountry requires language or country.
[warn] [AndroidDriver] Got language: 'undefined' and country: 'undefined'
[debug] [Logcat] Starting logcat capture
[debug] [AndroidDriver] Pushing unlock helper app to device...

10、安装 io.appium.unlock 到手机并启动

[debug] [ADB] Getting install status for io.appium.unlock
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell pm list packages io.appium.unlock'
[debug] [ADB] App is installed
[debug] [ADB] Getting package info for 'io.appium.unlock'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell dumpsys package io.appium.unlock'
[info] [ADB] Checking whether aapt is present
[warn] [ADB] The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for aapt.
[info] [ADB] Using aapt from D:\Program\Android Studio\SDK\build-tools\27.0.3\aapt.exe
[info] [ADB]

[debug] [ADB] The installed 'io.appium.unlock' package does not require upgrade ('2.0.0' >= '2.0.0')

11、获取设备信息
build.version 版本号

[info] [ADB] Getting device platform version
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell getprop ro.build.version.release'
[debug] [ADB] Current device property 'ro.build.version.release': 6.0

12、获取设备型号、分辨率及制造商信息

[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell wm size'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell getprop ro.product.model'
[debug] [ADB] Current device property 'ro.product.model': Google Nexus 6P - 6.0.0 - API 23 - 1440x2560
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell getprop ro.product.manufacturer'
[debug] [ADB] Current device property 'ro.product.manufacturer': Genymotion
[warn] [AndroidDriver] No app sent in, not parsing package/activity
[debug] [AndroidDriver] No app capability. Assuming it is already on the device

13、获取 app 安装状态

[debug] [ADB] Getting install status for com.xueqiu.android
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell pm list packages com.xueqiu.android'
[debug] [ADB] App is installed

14、强制停止 APP 进程并清除

[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell am force-stop com.xueqiu.android'
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell pm clear com.xueqiu.android'
[debug] [AndroidDriver] Performed fast reset on the installed 'com.xueqiu.android' application (stop and clear)

15、监听系统 4724 端口数据,并转发到设备 4724 端口

[debug] [AndroidBootstrap] Watching for bootstrap disconnect
[debug] [ADB] Forwarding system: 4724 to device: 4724
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 forward tcp:4724 tcp:4724'

16、启动 UiAutomator,push AppiumBootstrap.jar 到临时目录

[debug] [UiAutomator] Starting UiAutomator
[debug] [UiAutomator] Moving to state 'starting'
[debug] [UiAutomator] Parsing uiautomator jar
[debug] [UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 push C:\Users\dell\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium-android-bootstrap\bootstrap\bin\AppiumBootstrap.jar /data/local/tmp/'

17、清除 uiautomator 进程并重启

[debug] [ADB] Attempting to kill all uiautomator processes
[debug] [ADB] Getting all processes with uiautomator
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell ps'[info] [ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Starting UIAutomator
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","192.168.91.101:5555","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.xueqiu.android","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[debug] [UiAutomator] Moving to state 'online'

18、开启 socket 服务,解锁屏幕

[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[info] [AndroidBootstrap] Android bootstrap socket is now connected
[debug] [ADB] Getting connected devices...[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell dumpsys window'
[info] [AndroidDriver] Screen already unlocked, doing nothing
[debug] [ADB] Device API level: 23
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected

19、重新创建 sessionID

[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S'[info] [Appium] New AndroidDriver session created successfully, session 38ca78f8-4b34-4b0d-90b7-5b3c59014559 added to master session list
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1528772759697 (11:05:59 GMT+0800 (中国标准时间))
[debug] [MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"appActivity":".view.WelcomeActivityAlias","appPackage":"com.xueqiu.android","deviceName":"ddd","platformName":"android","newCommandTimeout":0,"connectHardwareKeyboard":true},"appActivity":".view.WelcomeActivityAlias","appPackage":"com.xueqiu.android","deviceName":"192.168.91.101:5555","platformName":"android","newCommandTimeout":0,"connectHardwareKeyboard":true,"deviceUDID":"192.168.91.101:5555","platformVersion":"6.0","deviceScreenSize":"1440x2560","deviceModel":"Google Nexus 6P - 6.0.0 - API 23 - 1440x2560","deviceManufacturer":"Genymotion"}

20、发送测试请求
通过 post 请求传递要查找的元素,appium 服务端进行接收,解析并将参数通过 4724 端口再次传递给 AndroidBootstrap,AndroidBootstrap 完成操作后将结果逐层返回

[info] [HTTP] <-- POST /wd/hub/session 200 6006 ms - 828

[info] [HTTP]

[info] [HTTP] --> POST /wd/hub/session/38ca78f8-4b34-4b0d-90b7-5b3c59014559/context

[info] [HTTP] {"name":"NATIVE_APP"}

[debug] [MJSONWP] Calling AppiumDriver.setContext() with args: ["NATIVE_APP","38ca78f8-4b34-4b0d-90b7-5b3c59014559"]
[debug] [AndroidDriver] Getting a list of available webviews
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\Program\Android Studio\SDK\platform-tools\adb.exe -P 5037 -s 192.168.91.101:5555 shell cat /proc/net/unix'
[debug] [AndroidDriver] Found webviews: []
[debug] [AndroidDriver] Available contexts: ["NATIVE_APP"]
[debug] [MJSONWP] Responding to client with driver.setContext() result: null
[info] [HTTP] <-- POST /wd/hub/session/38ca78f8-4b34-4b0d-90b7-5b3c59014559/context 200 112 ms - 76

[info] [HTTP] [info] [HTTP] --> GET /wd/hub/session/38ca78f8-4b34-4b0d-90b7-5b3c59014559/source

[info] [HTTP] {}

[debug] [MJSONWP] Calling AppiumDriver.getPageSource() with args: ["38ca78f8-4b34-4b0d-90b7-5b3c59014559"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"source","params":{}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"source","params":{}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: source
[debug] [AndroidBootstrap] [UIAUTO STDOUT] [APPIUM-UIAUTO] [debug] Returning result: {"status":0,"value":"<?xml version=\"1.0\" encoding=\"UTF-8\"?> [debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [AndroidBootstrap] [UIAUTO STDOUT] lse\" scrollable=\"false\" long-clickable=\"false\" password=\"false\" selected=\"false\" bounds=\"[254,1127][1185,1274]\" resource-id=\"com.xueqiu.android:id\/rl_login_by_wx\" instance=\"1\"><\/android.widget.RelativeLayout><\/android.widget.RelativeLayout><\/android.widget.FrameLayout><\/android.view.ViewGroup><\/android.widget.FrameLayout><\/android.widget.LinearLayout><\/android.widget.FrameLayout><\/hierarchy>"}[/APPIUM-UIAUTO]

[debug] [MJSONWP] Responding to client with driver.getPageSource() result: "<?xml version=\"1.0\" encoding=\"UTF-8\"?> [info] [HTTP] <-- GET /wd/hub/session/38ca78f8-4b34-4b0d-90b7-5b3c59014559/source 200 87 ms - 7053
[info] [HTTP]
[info] [HTTP] --> GET /wd/hub/session/38ca78f8-4b34-4b0d-90b7-5b3c59014559/screenshot

[info] [HTTP] {}

[debug] [MJSONWP] Calling AppiumDriver.getScreenshot() with args: ["38ca78f8-4b34-4b0d-90b7-5b3c59014559"]
[debug] [ADB] Device API level: 23[debug] [MJSONWP] Responding to client with driver.getScreenshot() result: "iVBORw0KGgoAAAANSUhEUgAABaAAAAoACAYAAABH9IXPAACAAElEQVR4AezB/W/Vh2Ev/rc/5/jh4EBDQgAfbGwMTWlZllSmSb8LadMqaPSBqluV/BBd5Vaa1u6HaZPuf3F/rPbLbX+Ypitrk3a3VVsrdRLpt0khK8sXUpqDIYFgHvwEeIQ8ge1jn+OvcqVe5Xo4JQ8n2PB6vdomJiYWAwAAAAAAH7MiAAAAAADQAkUAAAAAAKAFigAAAAAAQAsUAQAAAACAFigCAAAAAAAtUAQAAAAAAFqgCAAAAAAAtEARAAAAAABogSIAAAAAANACRQAAAAAAoAWKAAAAAABACxQBAAAAAIAWKAIAAAAAAC1QBAAAAAAAWqAIAAAAAAC0QDkAAAAAwIp24MCBXLhwIR/Wgw8+mF27dqVSqQQ+SeUAAAAAsGJMTk7mjTfeyOTkZCYnJzM7O5uZmZlMTk7m/VSr1VQqlXR1daVaraZarebuu+9OtVoNN2d0dDSDg4NZiS5cuJBXX301H9bmzZvzmc98JvBJKwcAAACAW2ZycjJnz57NmTNnMjo6mpmZmXwYk5OT+a2RkZH8VqVSyeDgYLZv355t27alWq2G/2x0dDTT09MZHBwM8PEpBwAAAIBP1OTkZI4ePZoTJ07k9ddfTyvNzMxkZGQkIyMjedc999yTz33ucxkaGkq1Wg3J6OhopqenA3z8ygEAAACg5a5evZqjR4/m6NGjef3113OrvP766zl06FAOHTqUe+65J0NDQ3n00UdTqVRyJxodHc309HSA1igHAAAAgJa5evVqnn322Rw5ciQrzeuvv54DBw7kwIED2b17d5544omsX78+d4rR0dFMT09nJThw4EAuXLiQ5UxMTOSjOH78eCYmJlIqlXIjDz74YHbv3h34uJUDAAAAwMfu6tWr+clPfpKRkZGsBkeOHMmRI0eye/fuPPHEE1m/fn1uZ6Ojo5mens5KceHChbz66qtplStXruTKlStZzubNmwOtUA4AAAAA...
[info] [HTTP] <-- GET /wd/hub/session/38ca78f8-4b34-4b0d-90b7-5b3c59014559/screenshot 200 2592 ms - 607202

[info] [HTTP]

[info] [HTTP] --> GET /wd/hub/session/38ca78f8-4b34-4b0d-90b7-5b3c59014559/window/current/size

[info] [HTTP] {}

[debug] [MJSONWP] Calling AppiumDriver.getWindowSize() with args: ["current","38ca78f8-4b34-4b0d-90b7-5b3c59014559"]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"getDeviceSize","params":{}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"getDeviceSize","params":{}}
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: getDeviceSize
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":{"height":2392,"width":1440}}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.getWindowSize() result: {"height":2392,"width":1440}
[info] [HTTP] <-- GET /wd/hub/session/38ca78f8-4b34-4b0d-90b7-5b3c59014559/window/current/size 200 11 ms - 100

[info] [HTTP] [info] [HTTP] --> GET /wd/hub/session

[info] [HTTP] {}

[debug] [HTTP] No route found. Setting content type to 'text/plain'
[info] [HTTP] <-- GET /wd/hub/session 404 1 ms - 57

[info] [HTTP]

[info] [HTTP] <-- GET /favicon.ico 200 22 ms - 1150

[info] [HTTP] [info] [HTTP] --> GET /

[info] [HTTP] {}

[debug] [HTTP] No route found. Setting content type to 'text/plain'
[info] [HTTP] <-- GET / 404 1 ms - 43

[info] [HTTP] [info] [HTTP] --> GET /

[info] [HTTP] {}

[debug] [HTTP] No route found. Setting content type to 'text/plain'
[info] [HTTP] <-- GET / 404 1 ms - 43

[info] [HTTP]

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册