错误信息:

ERROR: debug: Appium request initiated at /wd/hub/session
info: Using local app from desired caps: E:\app\workplace\Test\apps\ContactManager\ContactManager.apk
ERROR: debug: Request received with params: {"desiredCapabilities":{"platform":"WINDOWS","app":"E:\app\workplace\Test\apps\ContactManager\ContactManager.apk","browserName":"","appActivity":".ContactManager","device":"Android","appPackage":"com.example.android.contactmanager","version":"4.4"}}
info: Creating new appium session 61d85039-a97b-407f-9020-29d00fa7e3a2
ERROR: debug: Using fast reset? true
info: Starting android appium
info: Preparing device for session
info: Checking whether app is actually present
info: Checking whether adb is present
ERROR: debug: Getting connected emulators
info: [ADB] Using adb from E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe

info: Trying to find ws emulator
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe devices
info: [ADB] Getting connected devices...
ERROR: debug: 1 emulator(s) connected
info: [ADB] 1 device(s) connected
info: Sending telnet command to device: avd name
info: Getting running emulator port
info: Socket connection to device created
info: Socket connection to device ready
info: Telnet command got response: ws
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 wait-for-device
info: Found emulator ws in port 5554
info: Setting device id to emulator-5554
info: Did not launch AVD because it was already running.
info: [ADB] Waiting for device to be ready and to respond to shell commands (timeout = 5)
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "echo 'ready'"
info: Starting logcat capture
info: Getting device API level
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "getprop ro.build.version.sdk"
info: Device is at API Level 19
ERROR: debug: java -jar "E:\app\AppiumForWindows-1.0.0\AppiumForWindows\node_modules\appium\lib\devices\android\helpers\strings_from_apk.jar" "E:\app\workplace\Test\apps\ContactManager\ContactManager.apk" "C:\Windows\Temp\com.example.android.contactmanager"
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 push "C:\Windows\Temp\com.example.android.contactmanager\strings.json" /data/local/tmp
info: Checking whether aapt is present
ERROR: debug: Set app process to: .contactmanager
ERROR: debug: Not uninstalling app since server not started with --full-reset
ERROR: debug: Checking app cert for E:\app\workplace\Test\apps\ContactManager\ContactManager.apk: java -jar "E:\app\AppiumForWindows-1.0.0\AppiumForWindows\node_modules\appium\lib\devices\android\helpers\verify.jar" "E:\app\workplace\Test\apps\ContactManager\ContactManager.apk"
ERROR: debug: App already signed.
info: Zip-aligning E:\app\workplace\Test\apps\ContactManager\ContactManager.apk
info: Checking whether zipalign is present
info: [ADB] Using zipalign from E:\app\adt-bundle-windows-x86-20140321\sdk\tools\zipalign.exe

ERROR: debug: zipAlignApk: E:\app\adt-bundle-windows-x86-20140321\sdk\tools\zipalign.exe -f 4 "E:\app\workplace\Test\apps\ContactManager\ContactManager.apk" "C:\Users\ADMINI~1\AppData\Local\Temp\appium114419-9244-1s1puge.tmp"
info: MD5 for app is b2d2916bb5388e1dc281ec3e71ef1234
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "ls /data/local/tmp/b2d2916bb5388e1dc281ec3e71ef1234.apk"
ERROR: debug: Getting install status for com.example.android.contactmanager
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "pm list packages -3 com.example.android.contactmanager"
info: [ADB] App is installed
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "am force-stop com.example.android.contactmanager"
info: Running fast reset (stop and clear)
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "pm clear com.example.android.contactmanager"
info: [ADB] Forwarding system:4724 to device:4724
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 forward tcp:4724 tcp:4724
ERROR: debug: Pushing appium bootstrap to device...
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 push "E:\app\AppiumForWindows-1.0.0\AppiumForWindows\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
ERROR: debug: Pushing unlock helper app to device...
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 install "E:\app\AppiumForWindows-1.0.0\AppiumForWindows\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: Attempting to kill all 'uiautomator' processes
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "ps 'uiautomator'"
info: Getting all processes with 'uiautomator'
ERROR: debug: spawning: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap
info: No matching processes found
info: Running bootstrap
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [BOOTSTRAP] [info] Socket opened on port 4724
info: [BOOTSTRAP] [info] Appium Socket Server Ready
ERROR: debug: Waking up device if it's not alive
info: [BOOTSTRAP] [info] Loading json...
info: Pushing command to appium work queue: ["wake",{}]
info: [BOOTSTRAP] [info] json loading complete.
info: [BOOTSTRAP] [info] Registered crash watchers.
info: [BOOTSTRAP] [info] Client connected
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"wake","params":{}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: wake
info: [BOOTSTRAP] [info] Returning result: {"value":true,"status":0}
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "dumpsys window"
info: Writing dumpsys output to E:\app\AppiumForWindows-1.0.0\AppiumForWindows\node_modules\appium.dumpsys.log
ERROR: debug: Screen already unlocked, continuing.
info: Pushing command to appium work queue: ["getDataDir",{}]
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
ERROR: debug: dataDir set to: /data
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.example.android.contactmanager/.ContactManager"
info: [BOOTSTRAP] [debug] Got command action: getDataDir
info: [BOOTSTRAP] [info] Returning result: {"value":"\/data","status":0}
info: Waiting for activity to be focused
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "dumpsys window windows"
info: Getting focused package and activity
info: Device launched! Ready for commands
info: Setting command timeout to the default of 60 secs
info: Appium session started with sessionId 61d85039-a97b-407f-9020-29d00fa7e3a2
POST /wd/hub/session 303 57386ms - 9b
ERROR: debug: Appium request initiated at /wd/hub/session/61d85039-a97b-407f-9020-29d00fa7e3a2
info: Responding to client with success: {"status":0,"value":{"platform":"WINDOWS","browserName":"","platformVersion":"4.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"warnings":{},"desired":{"platform":"WINDOWS","app":"E:\app\workplace\Test\apps\ContactManager\ContactManager.apk","browserName":"","appActivity":".ContactManager","device":"Android","appPackage":"com.example.android.contactmanager","version":"4.4"},"app":"E:\app\workplace\Test\apps\ContactManager\ContactManager.apk","appActivity":".ContactManager","device":"Android","appPackage":"com.example.android.contactmanager","version":"4.4"},"sessionId":"61d85039-a97b-407f-9020-29d00fa7e3a2"}
ERROR: debug: Request received with params: {}
GET /wd/hub/session/61d85039-a97b-407f-9020-29d00fa7e3a2 200 3ms - 842b
ERROR: debug: Appium request initiated at /wd/hub/session/61d85039-a97b-407f-9020-29d00fa7e3a2/element
warn: [DEPRECATED] The "name" Locator strategy has been deprecated and will be removed. Please use the "accessibility id" Locator strategy instead.
ERROR: debug: Request received with params: {"using":"name","value":"Add Contact"}
info: Pushing command to appium work queue: ["find",{"strategy":"name","selector":"Add Contact","context":"","multiple":false}]
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"name","selector":"Add Contact","context":"","multiple":false}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: find
info: [BOOTSTRAP] [debug] Finding Add Contact using NAME with the contextId:
info: [BOOTSTRAP] [info] Returning result: {"value":{"ELEMENT":"1"},"status":0}
info: Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"61d85039-a97b-407f-9020-29d00fa7e3a2"}
POST /wd/hub/session/61d85039-a97b-407f-9020-29d00fa7e3a2/element 200 4907ms - 109b
ERROR: debug: Appium request initiated at /wd/hub/session/61d85039-a97b-407f-9020-29d00fa7e3a2/element/1/click
info: Pushing command to appium work queue: ["element:click",{"elementId":"1"}]
ERROR: debug: Request received with params: {"id":"1"}
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"1"}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: click
info: [BOOTSTRAP] [info] Returning result: {"value":true,"status":0}
info: Responding to client with success: {"status":0,"value":true,"sessionId":"61d85039-a97b-407f-9020-29d00fa7e3a2"}
POST /wd/hub/session/61d85039-a97b-407f-9020-29d00fa7e3a2/element/1/click 200 3818ms - 89b
info: Pushing command to appium work queue: ["find",{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}]
ERROR: debug: Appium request initiated at /wd/hub/session/61d85039-a97b-407f-9020-29d00fa7e3a2/elements
ERROR: debug: Request received with params: {"using":"class name","value":"android.widget.EditText"}
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"class name","selector":"android.widget.EditText","context":"","multiple":true}}
info: [BOOTSTRAP] [info] Got command of type ACTION
info: [BOOTSTRAP] [debug] Got command action: find
info: [BOOTSTRAP] [debug] Finding android.widget.EditText using CLASS_NAME with the contextId:
info: [BOOTSTRAP] [info] Element[] is null: (0)
info: [BOOTSTRAP] [info] Returning result: {"value":[],"status":0}
info: Responding to client with success: {"status":0,"value":[],"sessionId":"61d85039-a97b-407f-9020-29d00fa7e3a2"}
POST /wd/hub/session/61d85039-a97b-407f-9020-29d00fa7e3a2/elements 200 7584ms - 87b
ERROR: debug: executing: E:\app\adt-bundle-windows-x86-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "input keyevent 3"
info: Shutting down appium session...
info: [ADB] Pressing the HOME button
info: Stopping logcat capture
ERROR: debug: Logcat terminated with code null, signal SIGTERM
info: [BOOTSTRAP] [info] Got data from client: {"cmd":"shutdown"}
info: [BOOTSTRAP] [info] Got command of type SHUTDOWN
info: [BOOTSTRAP] [info] Returning result: {"value":"OK, shutting down","status":0}
info: [BOOTSTRAP] [info] Closed client connection
info: Sent shutdown command, waiting for UiAutomator to stop...
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [UIAUTOMATOR STDOUT] Time: 91.439
info: [UIAUTOMATOR STDOUT] OK (1 test)
info: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: UiAutomator shut down normally
info: Cleaning up android objects
info: Cleaning up appium session
info: We shut down because no new commands came in

脚本代码:

@Before
public void setUp() throws Exception {
// set up appium
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps/ContactManager");
File app = new File(appDir, "ContactManager.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device","Android");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability(CapabilityType.VERSION, "4.4");
capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.example.android.contactmanager");
capabilities.setCapability("appActivity", ".ContactManager");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}

/* @After
public void tearDown() throws Exception {
driver.quit();
}
*/
@Test
public void addContact(){
WebElement el = driver.findElement(By.name("Add Contact"));
el.click();
List textFieldsList = driver.findElementsByClassName("android.widget.EditText");
textFieldsList.get(0).sendKeys("Some Name");
textFieldsList.get(2).sendKeys("Some@example.com");
driver.swipe(100, 500, 100, 100, 2);
driver.findElementByName("Save").click();

}


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