Appium路径问题

时间:2017-11-20 16:06:10

标签: appium appium-android

我试图在appium中运行我的测试套件中的apk文件,模拟器成功运行但是在发布apk时它说没找到apk。这条路看起来对我来说仍然无法找到解决方案。

以下是Appium的错误。

AndroidDriver] Using device: emulator-5554
[ADB] Checking whether adb is present

[ADB] Using adb from /Library/Android/sdk/platform-tools/adb
[debug] [ADB] Setting device id to emulator-5554
[BaseDriver] Using local app '/src/test/resources/myapp.apk'
[debug] [AndroidDriver] Checking whether app is actually present

[debug] [AndroidDriver] Shutting down Android driver

[AndroidDriver] Cannot shut down Android driver; it has already shut down

[HTTP] <-- POST /wd/hub/session 500 25028 ms - 212 

[AndroidDriver] Error: Could not find app apk at /src/test/resources/myapp.apk
    at Object.wrappedLogger.errorAndThrow (lib/logger.js:60:13)
    at AndroidDriver.checkAppPresent$ (lib/driver.js:274:11)
    at tryCatch (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
    at run (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:104:47)
    at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/es6.promise.js:115:28
    at flush (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/babel-runtime/node_modules/core-js/library/modules/$.microtask.js:19:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)
 [Error: Could not find app apk at /src/test/resources/myapp.apk]

除了上面列出的路径之外,我尝试了以下路径: 1./src/test 2.从模块名称开始,该名称是/ src / test的一部分,即modulename / src / test 3.试过〜。/ src / test 4.试过〜/ src / test

关于我错过了什么的任何指示?

另外,为什么我在apk发布之前得到这个([debug] [AndroidDriver]关闭Android驱动程序)?

代码:

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.FULL_RESET,"true");      
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Nexus10");

   capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION,"4.4");   

 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");

     capabilities.setCapability(MobileCapabilityType.APP,"myapp.package");

    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "20");
        capabilities.setCapability("app", "/src/test/resources/myapp.apk");
        AndroidDriver = new AndroidDriver(new URL("http://127.0.0.1:4724/wd/hub"), capabilities);

        AndroidDriver.rotate(ScreenOrientation.PORTRAIT);
        log.info("Set up done for capabilities");

提前致谢。

1 个答案:

答案 0 :(得分:1)

如果&#39; src&#39;文件夹与您正在运行的位置相同,您想删除前面的&#39; /&#39;因为它告诉Appium从整个文件系统的根目录开始,而不是从本地路径开始。

src/test/resources/myapp.apk

我的经验是使用&#39;〜&#39;不适用于Appium。我个人已经参数化了应用程序位置,并将其从环境变量中拉出来,以说明它位于不同系统的不同位置,但在所有情况下,我都提供了文件系统根目录的路径,因为它最简单。