Skip to content

Appium android driver.isAppInstalled & driver.installApp #7387

@rkavalap

Description

@rkavalap

@rogertestevnt commented on Tue Mar 17 2015

Hi, I am using the code below to test an Android app using appium. However, the method driver.isAppInstalled does not return true when I do have the app installed in the device and the method
driver.installApp returns this error message:
org.openqa.selenium.WebDriverException: Unable to install [/walkman/apps/com.rdio.oi.android.ui-1.apk] to device with id [null]. Error [Error: spawn OK](WARNING: The server did not provide any stacktrace information)
Does anybody know how I can fix this issue?

### Code goes below

package dashboard.pageobjects.principal;

import static org.junit.Assert.*;
import java.net.URL;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.AppiumSetting;
import io.appium.java_client.MobileElement;
import io.appium.java_client.SwipeElementDirection;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class MainFlow {

AppiumDriver driver = null;
DesiredCapabilities capabilities = null;
WebDriverWait wait = null;

@BeforeClass
public void setUp() throws Exception {

    capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,
            MobilePlatform.ANDROID);
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,
            "Android device");
    capabilities.setCapability("device", "CB5A1X07H");
    capabilities.setCapability("appPackage", "com.sonyericsson.music");
    capabilities.setCapability("appActivity", ".MusicActivity");
    capabilities.setCapability("device-orientation", "portrait");
    capabilities.setCapability("locale", "en_US");
    capabilities.setCapability("language", "en");
    capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 120);

    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
            capabilities);
}

@AfterClass
public void tearDown() throws Exception {
    driver.quit();
}

@Test
public void test() throws InterruptedException {
    wait = new WebDriverWait(driver, 10);
    // By menu = By.className("android.widget.ImageButton");
    By disclaimer = By.id("com.sonyericsson.music:id/link");
    wait.until(ExpectedConditions.presenceOfElementLocated(disclaimer));
    driver.findElement(By.id("android:id/button1")).click();
    driver.swipe(20, 920, 890, 920, 0);
    if (driver.findElement(
            By.xpath("//android.widget.TextView[@text='Other Services']"))
            .isDisplayed());
    {
        //Install another app
        if(!driver.isAppInstalled("com.rdio.oi.android.ui"));
            //driver.installApp("apps/com.rdio.oi.android.ui-1.apk");
        driver.findElement(By.id("com.sonyericsson.music:id/artist2")).click();


    }

}

}


@shivakrishnach31 commented on Wed May 13 2015

@jlipps , @Jonahss ,

I am able to remove app using removeApp() from my iPad Air, but unable to install App from web URL(where my App build generated) using installApp().

Getting org.openqa.selenium.remote.SessionNotFoundException: exception.

Appim log:
info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Unable to install [com.shure.plus.channels] to device with id [188f6b571d77873782d16a972cff09253ded1f11]. Error [Error: Command failed: /bin/sh -c /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap install --id 188f6b571d77873782d16a972cff09253ded1f11 --bundle "com.shure.plus.channels"\nAssertion failed: (access(app_path, F_OK) == 0), function main, file fruitstrap.c, line 718.\n])","origValue":"Unable to install [com.shure.plus.channels] to device with id [188f6b571d77873782d16a972cff09253ded1f11]. Error [Error: Command failed: /bin/sh -c /Applications/Appium.app/Contents/Resources/node_modules/appium/build/fruitstrap/fruitstrap install --id 188f6b571d77873782d16a972cff09253ded1f11 --bundle "com.shure.plus.channels"\nAssertion failed: (access(app_path, F_OK) == 0), function main, file fruitstrap.c, line 718.\n]"},"sessionId":null}
info: <-- POST /wd/hub/session 500 4871.054 ms - 974


@wangyaolin commented on Tue Aug 11 2015

same problem here with using driver.isAppInstalled(). Can anybody help?


@Jonahss commented on Tue Aug 11 2015

@shivakrishnach31 You need to push the app file to the device first (using pushFile) and then choose install. The appium capabilities can install an app from a URL, but that code isn't in the installApp command that I know of.


@imurchie commented on Mon Feb 22 2016

Does this error (or these errors) still occur? Things are massively different now (no fruitstrap, etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions