0

I am trying to get my android app that I am creating using the maven android plugin to run my integration tests automatically on Saucelabs with Appium. Everything that I have tried so far has only given me the error "Failed to download mobile app: c:\workspace\android\android-it..\android-app\target\android-app.apk"

I am using sauceconnect in my integration test pom file with the following configuration:

<plugins>
         <plugin>
        <groupId>com.saucelabs.maven.plugin</groupId>
        <artifactId>sauce-connect-plugin</artifactId>
        <version>1.0.15</version>
        <configuration>
            <sauceUsername>MY USERNAME</sauceUsername>
            <sauceAccessKey>MY KEY</sauceAccessKey>
        </configuration>
        <executions>
            <!-- Start Sauce Connect prior to running the integration tests -->
            <execution>
                <id>start-sauceconnct</id>
                <phase>pre-integration-test</phase>
                <goals>
                    <goal>start-sauceconnect</goal>
                </goals>
            </execution>
            <!-- Stop the Sauce Connect process after the integration tests have finished -->
            <execution>
                <id>stop-sauceconnect</id>
                <phase>post-integration-test</phase>
                <goals>
                    <goal>stop-sauceconnect</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

My configuration for my appium test is done in my setup method and looks like this:

@Before
public void setUp() throws Exception {
    File classpathRoot = new File(System.getProperty("user.dir"));
    File app = new File(classpathRoot, "../android-app/target/android-app.apk");
    logger.info("PATH");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("appium-version", "1.0");
    capabilities.setCapability("apk", "sauce-storage:my_app.apk");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("platformVersion", "4.2");
    capabilities.setCapability("deviceName", "Android Emulator");
    capabilities.setCapability("deviceType", "phone");
    capabilities.setCapability("device","Android");
    capabilities.setCapability("app", app.getAbsolutePath());
    capabilities.setCapability("app-package", "com.android-app");
    capabilities.setCapability("app-activity", ".MainActivity");
    capabilities.setCapability("takesScreenshot", true);
    driver = new RemoteWebDriver(
            new URL("http://user:key@ondemand.saucelabs.com:80/wd/hub"),
            capabilities);
//        driver = new SwipeableWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}

According to everything that I've read on Saucelabs and Appium, this should allow my apk to download correctly and run when I run a maven build, however, as stated above, this doesn't seem to be the case. If anyone can provide me with pointers toward what I am missing I would greatly appreciate it.

David E
  • 17
  • 5

1 Answers1

0

You're trying to start a Sauce session with your local app path; Since that path isn't accessible to Sauce, it can't download the APK from it.

I assume either you're manually uploading your app, or your Maven config does so before each build. (Bonus hint: Make sure you pass the overwrite parameter, and have it true!)

If you set the 'app' capability to the value you're using for the 'apk' capability, the Sauce Storage reference, your tests should be able to download your app. As a side not, I'm not sure where the 'apk' capability your test uses has come from; Where in the Sauce Labs/Appium documentation is it referenced?

You also no longer need the app-package or app-activity capabilities for Appium 1.0.

Try these capabilities:

capabilities.setCapability("appium-version", "1.0");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "4.2");
capabilities.setCapability("deviceName", "Android Emulator");
capabilities.setCapability("deviceType", "phone");
capabilities.setCapability("app", "sauce-storage:my_app.apk");
capabilities.setCapability("takesScreenshot", true);
Dylan Lacey
  • 1,450
  • 9
  • 16