# 截取日志中的命令01
$ cat appium_20181104pm_default.log | grep -o "shell.*" |awk '{print "adb "$0 }' | awk -F "'" '{print $(NF-1)}' > appium_log
# 截取日志中的命令02
$ cat appium_20181104pm_default.log | grep -o "\-P.*" |awk -F "5555" '{print $(NF)}' |awk '{print "adb" $0}' | awk -F "'" '{print $(NF-1)}' > appium_log_default
– grep -o 只输出匹配到的部分
– awk : { } 类似循环体,对文本的每一行进行迭代
– awk:$0 执行过程当前行的的文本内容 $n 当前行的第n个字段,从1开始
– awk ‘{print "adb "$0 }’ : 对文本的每一行循环打印 adb + 当前行的文本内容
– awk:-F 分隔符
# 启动 appium server
info: [Appium] Welcome to Appium v1.9.1
info: [Appium] Non-default server args:
info: [Appium] sessionOverride: true
info: [Appium] log: appium_20181104pm.log
info: [Appium] Appium REST http interface listener started on 0.0.0.0:4723
#
info: [HTTP] --> POST /wd/hub/session
info: [HTTP] {
"capabilities":{
"firstMatch":[{
}],"alwaysMatch":{
"platformName":"Android","appium:deviceName":"192.168.121.101:5555","appium:appPackage":"com.xueqiu.android","appium:appActivity":".view.WelcomeActivityAlias","appium:udid":"192.168.121.101:5555"}},"desiredCapabilities":{
"platformName":"Android","deviceName":"192.168.121.101:5555","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","udid":"192.168.121.101:5555"}}
info: [debug] [W3C] Calling AppiumDriver.createSession() with args: [{
"platformName":"Android","deviceName":"192.168.121.101:5555","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","udid":"192.168.121.101:5555"},null,{
"firstMatch":[{
}],"alwaysMatch":{
"platformName":"Android","appium:deviceName":"192.168.121.101:5555","appium:appPackage":"com.xueqiu.android","appium:appActivity":".view.WelcomeActivityAlias","appium:udid":"192.168.121.101:5555"}}]
info: [debug] [BaseDriver] Event 'newSessionRequested' logged at 1541322488857 (17:08:08 GMT+0800 (中国标准时间))
info: [Appium] Creating new AndroidDriver (v4.1.1) session
info: [Appium] Capabilities:
info: [Appium] platformName: Android
info: [Appium] deviceName: 192.168.121.101:5555
info: [Appium] appPackage: com.xueqiu.android
info: [Appium] appActivity: .view.WelcomeActivityAlias
info: [Appium] udid: 192.168.121.101:5555
info: [debug] [BaseDriver] W3C capabilities {
"alwaysMatch":{
"platformNa... and MJSONWP desired capabilities {"platformName":"Android","... were provided
info: [debug] [BaseDriver] Creating session with W3C capabilities: {
"alwaysMatch":{
"platformNa...
info: [BaseDriver] Session created with session id: 25915561-eda3-4a33-afe4-120283b52aea
info: [AndroidDriver] Java version is: 1.8.0_181
info: [ADB] Checking whether adb is present
info: [ADB] Found 2 'build-tools' folders under 'C:\Users\liuji\AppData\Local\Android\Sdk' (newest first):
info: [ADB] C:/Users/liuji/AppData/Local/Android/Sdk/build-tools/28.0.3
info: [ADB] C:/Users/liuji/AppData/Local/Android/Sdk/build-tools/28.0.2
info: [ADB] Using adb.exe from C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe
info: [AndroidDriver] Retrieving device list
info: [debug] [ADB] Trying to find a connected android device
info: [debug] [ADB] Getting connected devices...
info: [debug] [ADB] 1 device(s) connected
info: [AndroidDriver] Using device: 192.168.121.101:5555
info: [debug] [ADB] Setting device id to 192.168.121.101:5555
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell getprop ro.build.version.sdk'
info: [debug] [ADB] Current device property 'ro.build.version.sdk': 23
info: [debug] [ADB] Device API level: 23
warn: [AndroidDriver] Consider setting 'automationName' capability to 'uiautomator2' on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
info: [AndroidDriver] App file was not listed, instead we're going to run com.xueqiu.android directly on the device
info: [debug] [AndroidDriver] Checking whether package is present on the device
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell pm list packages com.xueqiu.android'
info: [AndroidDriver] Starting Android session
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 wait-for-device'
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell echo ping'
info: [debug] [AndroidDriver] Pushing settings apk to device...
info: [debug] [ADB] Getting install status for io.appium.settings
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell pm list packages io.appium.settings'
info: [debug] [ADB] App is installed
info: [debug] [ADB] Getting package info for 'io.appium.settings'
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell dumpsys package io.appium.settings'
info: [ADB] Checking whether aapt is present
info: [ADB] Using aapt.exe from C:\Users\liuji\AppData\Local\Android\Sdk\build-tools\28.0.3\aapt.exe
info: [debug] [ADB] The installed 'io.appium.settings' package does not require upgrade ('2.3.0' >= '2.3.0')
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell ps'
info: [debug] [ADB] Device API level: 23
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
info: [debug] [ADB] Device API level: 23
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell appops set io.appium.settings android\:mock_location allow'
warn: [AndroidDriver] setDeviceLanguageCountry requires language or country.
warn: [AndroidDriver] Got language: 'null' and country: 'null'
info: [debug] [Logcat] Starting logcat capture
info: [debug] [AndroidDriver] Pushing unlock helper app to device...
info: [debug] [ADB] Getting install status for io.appium.unlock
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell pm list packages io.appium.unlock'
info: [debug] [ADB] App is installed
info: [debug] [ADB] Getting package info for 'io.appium.unlock'
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell dumpsys package io.appium.unlock'
info: [debug] [ADB] The installed 'io.appium.unlock' package does not require upgrade ('2.0.0' >= '2.0.0')
info: [ADB] Getting device platform version
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell getprop ro.build.version.release'
info: [debug] [ADB] Current device property 'ro.build.version.release': 6.0
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell wm size'
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell getprop ro.product.model'
info: [debug] [ADB] Current device property 'ro.product.model': Google Nexus 5X - 6.0.0 - API 23 - 1080x1920
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell getprop ro.product.manufacturer'
info: [debug] [ADB] Current device property 'ro.product.manufacturer': Genymotion
warn: [AndroidDriver] No app sent in, not parsing package/activity
info: [debug] [AndroidDriver] No app capability. Assuming it is already on the device
info: [debug] [ADB] Getting install status for com.xueqiu.android
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell pm list packages com.xueqiu.android'
info: [debug] [ADB] App is installed
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell am force-stop com.xueqiu.android'
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell pm clear com.xueqiu.android'
info: [debug] [AndroidDriver] Performed fast reset on the installed 'com.xueqiu.android' application (stop and clear)
info: [debug] [AndroidBootstrap] Watching for bootstrap disconnect
info: [debug] [ADB] Forwarding system: 4724 to device: 4724
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 forward tcp\:4724 tcp\:4724'
info: [debug] [UiAutomator] Starting UiAutomator
info: [debug] [UiAutomator] Moving to state 'starting'
info: [debug] [UiAutomator] Parsing uiautomator jar
info: [debug] [UiAutomator] Found jar name: 'AppiumBootstrap.jar'
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 push C\:\\Users\\liuji\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-android-driver\\bootstrap\\bin\\AppiumBootstrap.jar /data/local/tmp/'
info: [debug] [ADB] Attempting to kill all uiautomator processes
info: [debug] [ADB] Getting all processes with uiautomator
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell ps'
info: [ADB] No uiautomator process found to kill, continuing...
info: [debug] [UiAutomator] Starting UIAutomator
info: [debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","192.168.121.101:5555","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.xueqiu.android","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
info: [debug] [UiAutomator] Moving to state 'online'
info: [AndroidBootstrap] Android bootstrap socket is now connected
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell dumpsys window'
info: [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] json loading complete.
info: [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
info: [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
info: [AndroidDriver] Screen already unlocked, doing nothing
info: [debug] [ADB] Device API level: 23
info: [debug] [ADB] Running 'C:\Users\liuji\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 192.168.121.101\:5555 shell am start -W -n com.xueqiu.android/.view.WelcomeActivityAlias -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000'
info: [Appium] New AndroidDriver session created successfully, session 25915561-eda3-4a33-afe4-120283b52aea added to master session list
info: [debug] [BaseDriver] Event 'newSessionStarted' logged at 1541322498922 (17:08:18 GMT+0800 (中国标准时间))
info: [debug] [W3C] Cached the protocol value 'W3C' for the new session 25915561-eda3-4a33-afe4-120283b52aea
info: [debug] [W3C] 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":"192.168.121.101:5555","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","udid":"192.168.121.101:5555"},"platformName":"Android","deviceName":"192.168.121.101:5555","appPackage":"com.xueqiu.android","appActivity":".view.WelcomeActivityAlias","udid":"192.168.121.101:5555","deviceUDID":"192.168.121.101:5555","platformVersion":"6.0","deviceScreenSize":"1080x1920","deviceModel":"Google Nexus 5X - 6.0.0 - API 23 - 1080x1920","deviceManufacturer":"Genymotion"}}
info: [HTTP] <-- POST /wd/hub/session 200 10096 ms - 807
info: [HTTP]
info: [HTTP] --> POST /wd/hub/session/25915561-eda3-4a33-afe4-120283b52aea/timeouts
info: [HTTP] {"implicit":10000,"sessionId":"25915561-eda3-4a33-afe4-120283b52aea"}
info: [debug] [W3C] Calling AppiumDriver.timeouts() with args: [null,null,null,null,10000,"25915561-eda3-4a33-afe4-120283b52aea"]
info: [debug] [BaseDriver] W3C timeout argument: {"implicit":10000}}
info: [debug] [BaseDriver] Set implicit wait to 10000ms
info: [debug] [W3C] Responding to client with driver.timeouts() result: null
info: [HTTP] <-- POST /wd/hub/session/25915561-eda3-4a33-afe4-120283b52aea/timeouts 200 50 ms - 14
info: [HTTP]
info: [HTTP] --> POST /wd/hub/session/25915561-eda3-4a33-afe4-120283b52aea/element
info: [HTTP] {"using":"-android uiautomator","value":"new UiSelector().text(\"直播\")","sessionId":"25915561-eda3-4a33-afe4-120283b52aea"}
info: [debug] [W3C] Calling AppiumDriver.findElement() with args: ["-android uiautomator","new UiSelector().text(\"直播\")","25915561-eda3-4a33-afe4-120283b52aea"]
info: [debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
info: [debug] [BaseDriver] Waiting up to 10000 ms for condition
info: [debug] [AndroidBootstrap] Sending command to android: {
"cmd":"action","action":"find","params":{
"strategy":"-android uiautomator","selector":"new UiSelector().text(\"直播\")","context":"","multiple":false}}
info: [debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {
"cmd":"action","action":"find","params":{
"strategy":"-android uiautomator","selector":"new UiSelector().text(\"直播\")","context":"","multiple":false}}
info: [debug] [AndroidBootstrap] [BOOTSTRAP LOG