这是网上测试 ContactManager 的例子,一直运行失败,麻烦各位看一下哪位出错了,不知道是什么原因;应该是 capabilities 设置出错了,导致 driver 出错,但我也不知道具体在哪里出错了,求大神帮忙。下面是源码,再往下是日志。

File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps/ContactManager");
System.out.println(appDir.getAbsolutePath());
File app = new File(appDir, "ContactManager.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "Google Nexus S");
capabilities.setCapability("platformVersion", "4.2");
capabilities.setCapability("appPackage", "com.example.android.contactmanager");
capabilities.setCapability("appActivity", ".ContactManager");
capabilities.setCapability("app", app.getAbsolutePath());
driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

Starting Node Server
info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
ERROR: debug: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"18","automationName":"Appium"}
info: Appium REST http interface listener started on 127.0.0.1:4723
info: LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"platformVersion":"4.2","app":"E:\ilanlin\workspace\testmv\apps\ContactManager\ContactManager.apk","platformName":"Android","deviceName":"Google Nexus S","appActivity":".ContactManager","appPackage":"com.example.android.contactmanager"}}
ERROR: debug: Appium request initiated at /wd/hub/session
ERROR: debug: Request received with params: {"desiredCapabilities":{"platformVersion":"4.2","app":"E:\ilanlin\workspace\testmv\apps\ContactManager\ContactManager.apk","platformName":"Android","deviceName":"Google Nexus S","appActivity":".ContactManager","appPackage":"com.example.android.contactmanager"}}
info: Starting android appium
ERROR: debug: Using local app from desired caps: E:\ilanlin\workspace\testmv\apps\ContactManager\ContactManager.apk
ERROR: debug: Creating new appium session 44ed797b-dabc-422f-8e4c-a7a867e2e8fa
info: Retrieving device
ERROR: debug: Using fast reset? true
ERROR: debug: Preparing device for session
ERROR: debug: Checking whether app is actually present
ERROR: debug: Checking whether adb is present
ERROR: debug: Using adb from D:\Program Files\android-sdk-windows\platform-tools\adb.exe
ERROR: debug: Trying to find a connected android device
ERROR: debug: Getting connected devices...
ERROR: debug: executing: "D:\Program Files\android-sdk-windows\platform-tools\adb.exe" devices
ERROR: debug: 1 device(s) connected
info: Found device 192.168.56.101:5555
ERROR: debug: Setting device id to 192.168.56.101:5555
ERROR: debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
ERROR: debug: executing: "D:\Program Files\android-sdk-windows\platform-tools\adb.exe" -s 192.168.56.101:5555 wait-for-device
ERROR: debug: executing: "D:\Program Files\android-sdk-windows\platform-tools\adb.exe" -s 192.168.56.101:5555 shell "echo 'ready'"
ERROR: debug: Starting logcat capture
ERROR: error: Logcat capture failed: spawn ENOENT
ERROR: debug: Stopping logcat capture


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