I tried installing an apk using the command " driver.installApp("/Test Suite/Apps/com.android.chrome.apk")
, but it throws an error
Unable to install [/Test Suite/Apps/com.android.chrome.apk] to device with id [null]. Error [Error: spawn OK] (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 57 milliseconds
@ArunPG:- I think you have not mentioned device name caps, for me driver.installApp command is working fine.
send your complete code which you used. So may be we can help you.
if yes then where is caps= capabilities? have you defined desired capabilities ? for more details how to open browser on android device and run your tests refer below link. In description I have added sample code. download it and try it.
driver.installApp can install app in between the test, but first you need to define some capabilities to launch any other app first.
dr = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
dr.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Please let me know if I need to add any new capability to make the app install work and it would be very help full if you could paste your code where you have used the appinstall method.
See, through my caps, dialer activity will me launched as a default app and then it goes to my method browsing where it should install chrome application and then launch it.
See the code which i had pasted earlier for the browsing method.
Its simple as that i need to install an another app and launch it while running on another app
FYI:- Chrome is a browser and you can’t treat chrome just as a normal android app. Coming to your issue.
Every android devices already have chrome installed. In that case you don’t need to install chrome at all,
FYI : I am not running on an emulator nor my device has chrome application pre-installed and its not necessary that all the devices should have chrome app as different odm’s have different customisations.
Anyways my concern is not just for chrome app, its about how to install an app using the dr.installapp command.
Refer this code which is working fine for me. Hoping that it will help you to understand how it will work.
public class appInstalled {
AppiumDriver driver;
@BeforeClass
public void setUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","192.168.0.7:5555");
capabilities.setCapability("appPackage", "com.policybazaar");
capabilities.setCapability("appActivity","com.policybazaar.login.Splash_DashBoard"); // This is Launcher activity of your app (you can get it from apk info app)
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
}
@org.testng.annotations.Test
public void Test()
{
if(!driver.isAppInstalled("com.experitest.ExperiBank"))
{
driver.installApp("F:\\Learning\\automation_latest\\PolicyBazar\\apps\\EriBank.apk");
System.out.println("App is installed");
}
else
{
System.out.println("App is already installed");
driver.removeApp(("com.experitest.ExperiBank"));
System.out.println("App is Removed");
driver.installApp("F:\\Learning\\automation_latest\\PolicyBazar\\apps\\EriBank.apk");
}
}
public void f() throws InterruptedException, IOException {
File scrFile = ((TakesScreenshot) dr).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("E:\\update\\imran.png"));
dr.installApp("D:\\pjt\\supporting formats and apks\\android system info.apk");
errors
Unable to install [D:\pjt\supporting formats and apks\android system info.apk] to device with id [null]. Error [Error: spawn OK] (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 73 milliseconds
kindly tell me have you got some solutions for this////…