Prabhath
Prabhath

Reputation: 55

Appium path issue

I'm trying to run an apk file from my test suite in appium, the emulator runs successfully but at the time of launch of the apk it says apk not found. The path looks correct to me still unable to figure out the solution.

Below is the error from 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]

I tried following path apart from the one listed above: 1. ./src/test 2. Start from the module name which is part of /src/test i.e. modulename/src/test 3. Tried ~./src/test 4. Tried ~/src/test

Any pointers as to what is it that I'm missing?

Also, why am I getting this ([debug] [AndroidDriver] Shutting down Android driver) before the apk launch?

Code:

    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");

Thanks in advance.

Upvotes: 3

Views: 1489

Answers (1)

Mike Collins
Mike Collins

Reputation: 4549

If the 'src' folder is in the same location as you're running from, you want to remove the preceding '/' as that's telling Appium to look starting at the root of the entire file system rather than from your local path.

src/test/resources/myapp.apk

My experience is that using '~' does not work with Appium. I personally have parameterized the app location and pull it from an environment variable to account for it being in different places on different systems, but in all cases I provide the path from the file system root as it's simplest.

Upvotes: 1

Related Questions