-------------------------------这是初始化原码部分
public static AppiumDriver setUpAppium(String apkname,String version,String apppackage,String appactivity){
AppiumDriver appium = null;
File app=new File(System.getProperty("user.dir")+"//"+apkname); //"MobilePayment.apk"
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device","Android");
// capabilities.setCapability("automationName", "Appium");
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability(CapabilityType.VERSION, version); //"4.2.2"
capabilities.setCapability(CapabilityType.PLATFORM, "WINDOWS");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("app-package", apppackage); //"com.ysepay.mobileportal.activity"
capabilities.setCapability("app-activity", appactivity); //"com.ysepay.mobileportal.IndexActivity"
try {
appium = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
e.printStackTrace();
}
appium.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
return appium;
}
}
---------------------------------------------------报错日志-------------------------------
Starting Node Server
info: Welcome to Appium v1.1.0 (REV e433bbc31511f199287db7724e1ce692bcb32117)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: socket.io started
info: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"18","automationName":"Appium"}
ERROR: debug: Appium request initiated at /wd/hub/session
info: No appActivity desired capability or server param. Parsing from apk.
ERROR: debug: Request received with params: {"desiredCapabilities":{"platform":"WINDOWS","app":"D:\workspace\moblieAPP_automation\MobilePayment.apk","browserName":"","app-package":"com.ysepay.mobileportal.activity","device":"Android","app-activity":"com.ysepay.mobileportal.IndexActivity","version":"4.4"}}
info: No appPackage desired capability or server param. Parsing from apk.
ERROR: debug: Using fast reset? true
info: Using local app from desired caps: D:\workspace\moblieAPP_automation\MobilePayment.apk
info: Creating new appium session 602ccf2d-db0f-4ae6-873d-7d03fdc0945f
ERROR: debug: executing: "D:\android\android-sdk-windows\platform-tools\adb.exe" devices
info: Starting android appium
info: Preparing device for session
info: Checking whether app is actually present
info: Checking whether adb is present
info: [ADB] Using adb from D:\android\android-sdk-windows\platform-tools\adb.exe
info: Trying to find a connected android device
info: [ADB] Getting connected devices...
info: [ADB] 1 device(s) connected
ERROR: debug: executing: "D:\android\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 wait-for-device
info: Setting device id to emulator-5554
info: [ADB] Waiting for device to be ready and to respond to shell commands (timeout = 5)
ERROR: debug: executing: "D:\android\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 shell "echo 'ready'"
info: Starting logcat capture
info: Checking whether aapt is present
ERROR: debug: executing: "D:\android\android-sdk-windows\platform-tools\adb.exe" -s emulator-5554 shell "getprop ro.build.version.sdk"
info: Getting device API level
info: Device is at API Level 19
ERROR:Node Server Process Ended