无法在Windows上运行Junit Appium Android Test

时间:2014-05-28 08:58:15

标签: appium

我正在尝试使用Appium和Android模拟器运行Junit selenium测试。检测到设备,但我在下面这个突出显示的行中出现异常:

@Before
public void setUp() throws Exception{
   try{
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.VERSION, "4.4.2");
    capabilities.setCapability(CapabilityType.PLATFORM, "Windows");
    File app = new File("D:\\suman\\EMDocs\\Appium\\apps\\AndroidCalculator.APK");
    capabilities.setCapability("platformName","Android");
    capabilities.setCapability("deviceName","sumantest");
    capabilities.setCapability("deviceType","phone");
    capabilities.setCapability("app",app.getAbsolutePath());
    capabilities.setCapability("appPackage","com.calculator");
    driver = new RemoteWebDriver(new URL("http://<my local host>:<port>/wd/hub"), capabilities);
   }catch(Exception e){
     e.printStackTrace();
     throw e;
   }

 }

Appium控制台消息:

Starting Node Server
    > info: Welcome to Appium v1.0.0 (REV f0a00fab2335fa88cb355ab4dc43a9cd3f3236c0)
    > 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}
    > 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:\\suman\\EMDocs\\Appium\\apps\\AndroidCalculator.APK","platformName":"Android","deviceName":"sumantest","browserName":"Android","deviceType":"phone","appPackage":"com.calculator","version":"4.4.2"}}
    > info: Using local app from desired caps: D:\suman\EMDocs\Appium\apps\AndroidCalculator.APK
    > info: Creating new appium session 039c26b4-1b1f-4996-bfe0-78e413fd6842
    > 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
    > info: [ADB] Using adb from D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe
    > 
    > ERROR: debug: executing: D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe devices
    > info: Trying to find a connected android device
    > info: [ADB] Getting connected devices...
    > info: [ADB] 1 device(s) connected
    > ERROR: debug: executing: D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\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:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s emulator-5554 shell "echo 'ready'"
    > info: Starting logcat capture
    > info: Checking whether aapt is present
    > info: [ADB] Using aapt from D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\aapt.exe
    > 
    > ERROR: debug: packageAndLaunchActivityFromManifest: D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\aapt.exe dump badging D:\suman\EMDocs\Appium\apps\AndroidCalculator.APK
    > ERROR: debug: badging package: com.calculator
    > info: Getting device API level
    > ERROR: debug: badging act: com.calculator.Main
    > ERROR: debug: executing: D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-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 "D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\helpers\strings_from_apk.jar" "D:\suman\EMDocs\Appium\apps\AndroidCalculator.APK" "C:\Windows\Temp\com.calculator"
    > ERROR: debug: executing: D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s emulator-5554 push "C:\\Windows\\Temp\\com.calculator\\strings.json" /data/local/tmp
    > info: Checking whether aapt is present
    > info: [ADB] Using aapt from D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\aapt.exe
    > 
    > ERROR: debug: processFromManifest: D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\aapt.exe dump xmltree "D:\suman\EMDocs\Appium\apps\AndroidCalculator.APK" AndroidManifest.xml
    > ERROR: debug: Set app process to: com.calculator
    > ERROR: debug: Not uninstalling app since server not started with --full-reset
    > ERROR: debug: Checking app cert for D:\suman\EMDocs\Appium\apps\AndroidCalculator.APK: java -jar "D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\helpers\verify.jar" "D:\suman\EMDocs\Appium\apps\AndroidCalculator.APK"
    > ERROR: debug: App already signed.
    > info: Zip-aligning D:\suman\EMDocs\Appium\apps\AndroidCalculator.APK
    > info: Checking whether zipalign is present
    > info: [ADB] Using zipalign from D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\tools\zipalign.exe
    > 
    > ERROR: debug: zipAlignApk: D:\suman\EMDocs\Appium\AndroidSDK\adt-bundle-windows-x86_64-20140321\sdk\tools\zipalign.exe -f 4 "D:\suman\EMDocs\Appium\apps\AndroidCalculator.APK" "C:\Users\SUMANK~1.ORA\AppData\Local\Temp\appium114428-8124-1i5kl3w.tmp"
    > ERROR: error: uncaughtException: Uncaught, unspecified "error" event. date=Wed May 28 2014 10:35:30 GMT+0530 (India Standard Time), pid=8124, uid=null, gid=null, cwd=D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium, execPath=D:\suman\EMDocs\Appium\AppiumForWindows\node.exe, version=v0.10.26, argv=[D:\suman\EMDocs\Appium\AppiumForWindows\node.exe, D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\server\main.js, --address, 127.0.0.1, --port, 4723, --log-no-color], rss=43081728, heapTotal=31562588, heapUsed=16595348, loadavg=[0, 0, 0], uptime=2662.6549344, trace=[column=null, file=null, function=TypeError, line=null, method=null, native=false, column=15, file=events.js, function=EventEmitter.emit, line=74, method=emit, native=false, column=15, file=D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\node_modules\md5calculator\src\calculator.js, function=module.exports, line=16, method=exports, native=false, column=3, file=D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\android-common.js, function=androidCommon.getAppMd5, line=469, method=getAppMd5, native=false, column=10, file=D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\android-common.js, function=androidCommon.getRemoteApk, line=369, method=getRemoteApk, native=false, column=8, file=D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\android-common.js, function=androidCommon.remoteApkExists, line=378, method=remoteApkExists, native=false, column=10, file=D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\android-common.js, function=, line=415, method=null, native=false, column=7, file=D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\adb.js, function=, line=1360, method=null, native=false, column=7, file=D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\adb.js, function=null, line=493, method=null, native=false, column=15, file=fs.js, function=Object.oncomplete, line=107, method=oncomplete, native=false], stack=[TypeError: Uncaught, unspecified "error" event.,     at TypeError (<anonymous>),     at EventEmitter.emit (events.js:74:15),     at module.exports (D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\node_modules\md5calculator\src\calculator.js:16:15),     at androidCommon.getAppMd5 (D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\android-common.js:469:3),     at androidCommon.getRemoteApk (D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\android-common.js:369:10),     at androidCommon.remoteApkExists (D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\android-common.js:378:8),     at null.<anonymous> (D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\android-common.js:415:10),     at null.<anonymous> (D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\adb.js:1360:7),     at D:\suman\EMDocs\Appium\AppiumForWindows\node_modules\appium\lib\devices\android\adb.js:493:7,     at Object.oncomplete (fs.js:107:15)]
    > ERROR: 
    > 
    > Node Server Process Ended

对此的任何指示都将非常感激。

2 个答案:

答案 0 :(得分:3)

您必须提及启动器活动类名称才能启动该应用程序。添加以下功能:

 capabilities.setCapability("appActivity",".[Activity_Name]");

答案 1 :(得分:2)

解决了这个问题。 我只需从项目中删除google collections.jar文件。 之后测试结束了。