Appium查看日志,获取当中的adb和http操作

多看Appium的日志有助于了解底层实现

创建对应的session

[HTTP]
 {"capabilities":{"firstMatch":[{"platformName":"android",
"appium:deviceName":"8XV7N16219000720",
#可以输入中文
"appium:unicodeKeyboard":"true",
"appium:appPackage":"com.xueqiu.android",
"appium:appActivity":".view.WelcomeActivityAlias",
#还原键盘
"appium:resetKeyboard":"true",
#自动授权给app
"appium:autoGrantPermissions":"true"}]},

隐式等待的时间为10秒,sessionId

[HTTP] {"implicit":10000,"sessionId":"db884382-e1d5-4473-ad1c-d7d6f2aa0430"}

查找adb的环境变量

[ADB] Checking whether adb is present

查找build-tools的环境变量

[ADB] Found 27 'build-tools' folders under '/Users/a/Desktop/android-sdk-macosx' (newest first):

输出使用adb的目录

[ADB] Using adb from /Users/a/Desktop/android-sdk-macosx/platform-tools/adb

连接设备id:ee9d91f6

[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[AndroidDriver] Using device: ee9d91f6
[ADB] Setting device id to ee9d91f6

getprop 查看 Android 设备的参数信息
结果以 key : value 键值对的形式显示,这里是获取sdk的版本

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell getprop ro.build.version.sdk'

当前设备sdk的api是22

[ADB] Current device property 'ro.build.version.sdk': 22
[ADB] Device API level: 22

查看包名com.xueqiu.android是否存在

 [ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell pm list packages com.xueqiu.android'

能否正常连接上设备

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 wait-for-device'
[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell echo ping'

获取包名io.appium.settings的信息

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell dumpsys package io.appium.settings'

运行在Android设备上的adb后台进程

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell ps'

通过pm命令,给io.appium.settings授权

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell pm grant io.appium.settings android.permission.SET_ANIMATION_SCALE \; pm grant io.appium.settings 

启动指定的activity

-W等待启动完成
-n指定包名io.appium.settings/.Settings
-a : 指定Intent action

 [ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c 

通过ime命令设置输入法

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell ime enable io.appium.settings/.UnicodeIME'
[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell ime set io.appium.settings/.UnicodeIME'

获取屏幕尺寸

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell wm size'

获取手机型号

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell getprop ro.product.model'

获取手机品牌

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell getprop ro.product.manufacturer'

获取com.xueqiu.android包的信息,判断是否安装

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell dumpsys package com.xueqiu.android'
[ADB] 'com.xueqiu.android' is installed

结束雪球app的进程


[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell am force-stop com.xueqiu.android'

清除雪球app的应用信息

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell pm clear com.xueqiu.android'

所有发往宿主机 4724 端口的消息、数据都会转发到 Android 设备的 4724 端口上

[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 forward tcp\:4724 tcp\:4724'

推送AppiumBootstrap.jar至 Android 设备

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 push /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/bootstrap/bin/AppiumBootstrap.jar /data/local/tmp/'

通过ps命令来获取android后台进程,没有uiautomator的进程,则启动uiautomator

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell ps'
[ADB] No 'uiautomator' process has been found
[UiAutomator] Starting UIAutomator

获取window的信息

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell dumpsys window'

设置输入法

[ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell ime set com.google.android.inputmethod.pinyin/.PinyinIME'

3 --> “KEYCODE_HOME”,执行回到桌面操作

2019-02-27 04:56:06:987 [ADB] Running '/Users/a/Desktop/android-sdk-macosx/platform-tools/adb -P 5037 -s ee9d91f6 shell input keyevent 3'

你可能感兴趣的:(新技能)