问题描述:
正常启动 appium 服务, 在 eclipse 中右键 Run as TestNG Test 之后, apk 可以正常安装并启动, 但是总会在 btn.click();处报错, 错误为 java.lang.NullPointerException.
我仔细看了 appium 的日志, [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"ELEMENT":"1"},"status":0}, 说明找得到这个控件, 但是一调用该控件的.click() 方法就出错了. 有大家遇到和我一样的问题么????
完整的脚本及错误日志如下;
运行环境:
eclipse
jdk 1.8.0_131
appium 1.6.5
java 脚本

package appium;

import java.io.File;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By.ById;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import io.appium.java_client.android.AndroidDriver;

public class testDemo {
    AndroidDriver driver;
    SDK sdk = new SDK("360");

    @BeforeMethod(alwaysRun = true)
    public void setUp() throws Exception {
        File classpathRoot = new File(System.getProperty("user.dir"));
        File appDir = new File(classpathRoot, "apps");
        File app = new File(appDir, "ContactManager.apk");
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("appium-version", "1.6.5");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("deviceName", "vivo X5L");
        capabilities.setCapability("udid", "BMBY8LU4YTMBS8SO");
        capabilities.setCapability("platformVersion", "4.4.2");
        capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("appPackage", "com.example.android.contactmanager");
        capabilities.setCapability("appActivity", ".ContactManager");
        driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
    }

    @AfterMethod(alwaysRun = true)
    public void tearDown() throws Exception {
        driver.quit();
    }

    @Test(groups = { "test" })
    public void test() {
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);    
        WebElement btn=driver.findElement(ById.id("com.example.android.contactmanager:id/addContactButton"));       
        btn.click();
        List<WebElement> textFieldsList = driver.findElementsByClassName("android.widget.EditText");
        textFieldsList.get(0).sendKeys("JerryWang");
        textFieldsList.get(1).sendKeys("12345678901");
        textFieldsList.get(2).sendKeys("jerry@wang.com");
        driver.swipe(100, 500, 100, 100, 2);
        driver.findElementByName("Save").click();
    }
}

eclipse console 的报错信息

FAILED: test
java.lang.NullPointerException
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:275)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:82)
    at appium.testDemo.test(testDemo.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:744)
    at org.testng.TestRunner.run(TestRunner.java:602)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
    at org.testng.SuiteRunner.run(SuiteRunner.java:289)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
    at org.testng.TestNG.runSuites(TestNG.java:1144)
    at org.testng.TestNG.run(TestNG.java:1115)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)


===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

appium 的日志

[Appium] Welcome to Appium v1.6.5
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session {"capabilities":[{"desiredCapabilities":{"app":"D:\\workspace_new\\appium\\apps\\Contact
Manager.apk","appPackage":"com.example.android.contactmanager","appActivity":".ContactManager","appium-version":"1.6.5",
"platformVersion":"4.4.2","browserName":"","platformName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName":"vivo X5L"}},
{"requiredCapabilities":{}}],"desiredCapabilities":{"app":"D:\\workspace_new\\appium\\apps\\ContactManager.apk","appPack
age":"com.example.android.contactmanager","appActivity":".ContactManager","appium-version":"1.6.5","platformVersion":"4.
4.2","browserName":"","platformName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName":"vivo X5L"},"requiredCapabilities"
:{}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"D:\\workspace_new\\appium\\apps\\ContactManag
er.apk","appPackage":"com.example.android.contactmanager","appActivity":".ContactManager","appium-version":"1.6.5","plat
formVersion":"4.4.2","browserName":"","platformName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName":"vivo X5L"},{},[{"
desiredCapabilities":{"app":"D:\\workspace_new\\appium\\apps\\ContactManager.apk","appPackage":"com.example.android.cont
actmanager","appActivity":".ContactManager","appium-version":"1.6.5","platformVersion":"4.4.2","browserName":"","platfor
mName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName":"vivo X5L"}},{"requiredCapabilities":{}}]]
[debug] [BaseDriver] Event 'newSessionRequested' logged at 1503389706281 (16:15:06 GMT+0800 (中国标准时间))
[Appium] Creating new AndroidDriver (v1.20.0) session
[Appium] Capabilities:
[Appium]   app: 'D:\\workspace_new\\appium\\apps\\ContactManager.apk'
[Appium]   appPackage: 'com.example.android.contactmanager'
[Appium]   appActivity: '.ContactManager'
[Appium]   appium-version: '1.6.5'
[Appium]   platformVersion: '4.4.2'
[Appium]   browserName: ''
[Appium]   platformName: 'Android'
[Appium]   udid: 'BMBY8LU4YTMBS8SO'
[Appium]   deviceName: 'vivo X5L'
[debug] [AndroidDriver] AndroidDriver version: 1.20.0
[BaseDriver] The following capabilities were provided, but are not recognized by appium: appium-version.
[BaseDriver] Session created with session id: 6cf6350c-36b3-4747-a044-cf9c13643f32
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_131
[ADB] Checking whether adb is present
[ADB] Using adb.exe from D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe
[AndroidDriver] Retrieving device list
[debug] [ADB] Trying to find a connected android device
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[AndroidDriver] Using device: BMBY8LU4YTMBS8SO
[ADB] Checking whether adb is present
[ADB] Using adb.exe from D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe
[debug] [ADB] Setting device id to BMBY8LU4YTMBS8SO
[BaseDriver] Using local app 'D:\workspace_new\appium\apps\ContactManager.apk'
[debug] [AndroidDriver] Checking whether app is actually present
[AndroidDriver] Starting Android session
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","wait-for-device"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","echo","ping"]
[debug] [Logcat] Starting logcat capture
[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:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","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...
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from D:\adt-bundle-windows-x86_64-20140321\sdk\build-tools\android-4.4.2\aapt.exe
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","dumpsys","package","io.appium.settings"]
[ADB] Cannot read version codes of C:\Users\wangjiarui\AppData\Roaming\npm\node_modules\appium\node_modules\io.appium.se
ttings\app\build\outputs\apk\settings_apk-debug.apk and/or io.appium.settings. Assuming correct app version is already i
nstalled
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","getprop","ro.build.version.sdk"]
[debug] [ADB] Device API level: 19
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","dumpsys","package","io.appium.settings"]
[debug] [AndroidDriver] Pushing unlock helper app to device...
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","install","C:\\Users\\wangjiarui\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-unloc
k\\bin\\unlock_apk-debug.apk"]
[debug] [ADB] Device API level: 19
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","settings","put","secure","mock_location","1"]
[ADB] Getting device platform version
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","getprop","ro.build.version.release"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","wm","size"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","getprop","ro.product.model"]
[debug] [ADB] Current device property 'ro.product.model': vivo X5L
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","getprop","ro.product.manufacturer"]
[debug] [ADB] Current device property 'ro.product.manufacturer': BBK
[AndroidDriver] Remote apk path is /data/local/tmp/b2d2916bb5388e1dc281ec3e71ef1234.apk
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","ls","/data/local/tmp/b2d2916bb5388e1dc281ec3e71ef1234.apk"]
[debug] [AndroidDriver] Checking if app is installed
[debug] [ADB] Getting install status for com.example.android.contactmanager
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","pm","list","packages","com.example.android.contactmanager"]
[debug] [ADB] App is installed
[AndroidDriver] Apk is already on remote and installed, resetting
[debug] [AndroidDriver] Running fast reset (stop and clear)
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","am","force-stop","com.example.android.contactmanager"]
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","pm","clear","com.example.android.contactmanager"]
[debug] [AndroidDriver] Extracting strings from apk D:\workspace_new\appium\apps\ContactManager.apk null C:\Users\WANGJI
~1\AppData\Local\Temp\com.example.android.contactmanager
[debug] [ADB] Extracting strings for language: default
[debug] [ADB] Device API level: 19
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","getprop","persist.sys.language"]
[debug] [ADB] Current device property 'persist.sys.language':
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","getprop","ro.product.locale.language"]
[debug] [ADB] Current device property 'ro.product.locale.language': zh
[debug] [ADB] No strings.xml for language 'zh', getting default strings.xml
[debug] [ADB] Reading strings from converted strings.json
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","push","C:\\Users\\WANGJI~1\\AppData\\Local\\Temp\\com.example.android.contactmanager\\strings.json","/da
ta/local/tmp"]
[debug] [AndroidBootstrap] Watching for bootstrap disconnect
[debug] [ADB] Forwarding system: 4724 to device: 4724
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","forward","tcp:4724","tcp:4724"]
[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:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","push","C:\\Users\\wangjiarui\\AppData\\Roaming\\npm\\node_modules\\appium\\node_modules\\appium-android-
bootstrap\\bootstrap\\bin\\AppiumBootstrap.jar","/data/local/tmp/"]
[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:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Starting UIAutomator
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","BMBY8LU4YTMBS8SO","shell","uiautomator","runtest","App
iumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.example.android.contactmanager","-e","dis
ableAndroidWatchers",false,"-e","acceptSslCerts",false]
[debug] [UiAutomator] Moving to state 'online'
[AndroidBootstrap] Android bootstrap socket is now connected
[debug] [ADB] Getting connected devices...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","dumpsys","window"]
[AndroidDriver] Screen already unlocked, doing nothing
[debug] [ADB] Device API level: 19
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","am","start","-W","-n","com.example.android.contactmanager/.ContactManager","-S","-a","android.in
tent.action.MAIN","-c","android.intent.category.LAUNCHER","-f","0x10200000"]
[Appium] New AndroidDriver session created successfully, session 6cf6350c-36b3-4747-a044-cf9c13643f32 added to master se
ssion list
[debug] [BaseDriver] Event 'newSessionStarted' logged at 1503389722286 (16:15:22 GMT+0800 (中国标准时间))
[debug] [MJSONWP] Responding to client with driver.createSession() result: {"platform":"LINUX","webStorageEnabled":false
,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContex
tEnabled":false,"warnings":{},"desired":{"app":"D:\\workspace_new\\appium\\apps\\ContactManager.apk","appPackage":"com.e
xample.android.contactmanager","appActivity":".ContactManager","appium-version":"1.6.5","platformVersion":"4.4.2","brows
erName":"","platformName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName":"vivo X5L"},"app":"D:\\workspace_new\\appium\
\apps\\ContactManager.apk","appPackage":"com.example.android.contactmanager","appActivity":".ContactManager","appium-ver
sion":"1.6.5","platformVersion":"4.4.2","browserName":"","platformName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName"
:"BMBY8LU4YTMBS8SO","deviceUDID":"BMBY8LU4YTMBS8SO","deviceScreenSize":"720x1280","deviceModel":"vivo X5L","deviceManufa
cturer":"BBK"}
[HTTP] <-- POST /wd/hub/session 200 16023 ms - 971
[HTTP] --> GET /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32 {}
[debug] [MJSONWP] Calling AppiumDriver.getSession() with args: ["6cf6350c-36b3-4747-a044-cf9c13643f32"]
[debug] [MJSONWP] Responding to client with driver.getSession() result: {"platform":"LINUX","webStorageEnabled":false,"t
akesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEn
abled":false,"warnings":{},"desired":{"app":"D:\\workspace_new\\appium\\apps\\ContactManager.apk","appPackage":"com.exam
ple.android.contactmanager","appActivity":".ContactManager","appium-version":"1.6.5","platformVersion":"4.4.2","browserN
ame":"","platformName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName":"vivo X5L"},"app":"D:\\workspace_new\\appium\\ap
ps\\ContactManager.apk","appPackage":"com.example.android.contactmanager","appActivity":".ContactManager","appium-versio
n":"1.6.5","platformVersion":"4.4.2","browserName":"","platformName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName":"B
MBY8LU4YTMBS8SO","deviceUDID":"BMBY8LU4YTMBS8SO","deviceScreenSize":"720x1280","deviceModel":"vivo X5L","deviceManufactu
rer":"BBK"}
[HTTP] <-- GET /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32 200 16 ms - 971
[HTTP] --> GET /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32 {}
[debug] [MJSONWP] Calling AppiumDriver.getSession() with args: ["6cf6350c-36b3-4747-a044-cf9c13643f32"]
[debug] [MJSONWP] Responding to client with driver.getSession() result: {"platform":"LINUX","webStorageEnabled":false,"t
akesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEn
abled":false,"warnings":{},"desired":{"app":"D:\\workspace_new\\appium\\apps\\ContactManager.apk","appPackage":"com.exam
ple.android.contactmanager","appActivity":".ContactManager","appium-version":"1.6.5","platformVersion":"4.4.2","browserN
ame":"","platformName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName":"vivo X5L"},"app":"D:\\workspace_new\\appium\\ap
ps\\ContactManager.apk","appPackage":"com.example.android.contactmanager","appActivity":".ContactManager","appium-versio
n":"1.6.5","platformVersion":"4.4.2","browserName":"","platformName":"Android","udid":"BMBY8LU4YTMBS8SO","deviceName":"B
MBY8LU4YTMBS8SO","deviceUDID":"BMBY8LU4YTMBS8SO","deviceScreenSize":"720x1280","deviceModel":"vivo X5L","deviceManufactu
rer":"BBK"}
[HTTP] <-- GET /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32 200 15 ms - 971
[HTTP] --> POST /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32/timeouts {"type":"implicit","ms":30000}
[debug] [MJSONWP] Calling AppiumDriver.timeouts() with args: ["implicit",30000,"6cf6350c-36b3-4747-a044-cf9c13643f32"]
[debug] [BaseDriver] Set implicit wait to 30000ms
[debug] [MJSONWP] Responding to client with driver.timeouts() result: null
[HTTP] <-- POST /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32/timeouts 200 5 ms - 76
[HTTP] --> POST /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32/element {"using":"id","value":"com.example.android.
contactmanager:id/addContactButton"}
[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["id","com.example.android.contactmanager:id/addContactB
utton","6cf6350c-36b3-4747-a044-cf9c13643f32"]
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiauto
mator
[debug] [BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiauto
mator
[debug] [BaseDriver] Waiting up to 30000 ms for condition
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"action","action":"find","params":{"strategy":"id","select
or":"com.example.android.contactmanager:id/addContactButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"i
d","selector":"com.example.android.contactmanager:id/addContactButton","context":"","multiple":false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding 'com.example.android.contactmanager:id/addContactButton' using 'ID' w
ith the contextId: '' multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.example.android.contactmanager:
id/addContactButton]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":{"ELEMENT":"1"},"status":0}
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"1"}
[HTTP] <-- POST /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32/element 200 1188 ms - 87
[HTTP] --> DELETE /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32 {}
[debug] [MJSONWP] Calling AppiumDriver.deleteSession() with args: ["6cf6350c-36b3-4747-a044-cf9c13643f32"]
[debug] [BaseDriver] Event 'quitSessionRequested' logged at 1503389723600 (16:15:23 GMT+0800 (中国标准时间))
[debug] [AndroidDriver] Shutting down Android driver
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","am","force-stop","com.example.android.contactmanager"]
[debug] [ADB] Pressing the HOME button
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","input","keyevent",3]
[debug] [AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"value":"OK, shutting down","status":0}
[debug] [AndroidBootstrap] [UIAUTO STDOUT] [CDS]close[4724]
[debug] [AndroidBootstrap] Received command result from bootstrap
[debug] [UiAutomator] Shutting down UiAutomator
[debug] [UiAutomator] Moving to state 'stopping'
[debug] [AndroidBootstrap] [UIAUTO STDOUT] close [socket][/0.0.0.0:4724]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: current=1
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: 0
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Test results for WatcherResultPrinter=.
[debug] [AndroidBootstrap] [UIAUTO STDOUT] Time: 4.845
[debug] [AndroidBootstrap] [UIAUTO STDOUT] OK (1 test)
[debug] [AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS_CODE: -1
[debug] [UiAutomator] UiAutomator shut down normally
[debug] [UiAutomator] Moving to state 'stopped'
[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:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[debug] [UiAutomator] Moving to state 'stopped'
[debug] [Logcat] Stopping logcat capture
[debug] [ADB] Getting connected devices...
[debug] [ADB] 1 device(s) connected
[debug] [ADB] Running 'D:\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","BMB
Y8LU4YTMBS8SO","shell","am","force-stop","io.appium.unlock"]
[debug] [AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[Appium] Removing session 6cf6350c-36b3-4747-a044-cf9c13643f32 from our master session list
[debug] [BaseDriver] Event 'quitSessionFinished' logged at 1503389726298 (16:15:26 GMT+0800 (中国标准时间))
[debug] [MJSONWP] Received response: null
[debug] [MJSONWP] But deleting session, so not returning
[debug] [MJSONWP] Responding to client with driver.deleteSession() result: null
[HTTP] <-- DELETE /wd/hub/session/6cf6350c-36b3-4747-a044-cf9c13643f32 200 2710 ms - 76


↙↙↙阅读原文可查看相关链接,并与作者交流