I need to check whether application is already installed in device !!How to get the instance to the driver before or after connecting to Server before installation of application.
Something like:
if(driver.isAppInstalled(“ABC”) == false)
{
then connect to Appium Server(URL ,Capabilities);
}
else
{
install the application
}
I was trying to automate the Android application.So,after Appium Server connects to mobile and before application is launched at this Point of Time I need to check for the condition whether app is installed or not.
So as @afwang said, just use the adb command at that point. You can just make a system call to ‘adb shell pm list packages’ and parse the result. Since the driver is invalid, don’t use it.
My code is in Ruby, which I doubt you are using (most around here use Java). Instead, why don’t you share what you’ve tried and tell what’s not working? Your description of the problem is decidedly lacking in details.
Ok, so here is where you are stuck. The driver is not instantiated and you want to check the device to see if the app is installed. So instead of using the above code you’ll need to make a system call to adb. Here is a tutorial on making a system call from Java:
Just sub in the commands that were given above (‘adb shell pm list packages’) and parse the results.
Hi, I am trying as per your suggestion but unable to implement it properly.If possible please share code
I have got list of connected devices but unable to check installed app
Code like that:
AndroidDebugBridge.init(false);
AndroidDebugBridge debugBridge = AndroidDebugBridge.createBridge("C:\\adb.exe", true);
if (debugBridge == null) {
System.err.println("Invalid ADB location.");
System.exit(1);
}
AndroidDebugBridge.addDeviceChangeListener(new IDeviceChangeListener() {
@Override
public void deviceChanged(IDevice device, int arg1) {
}
@Override
public void deviceConnected(IDevice device) {
System.out.println(String.format("%s connected", device.getSerialNumber()));
}
Sounds like you need to get the UDID (aka UUID) of the device you want to test, and then craft a command that gets all the installed apps on that device (and then parse that).
You want to see my code, and I’ve told you it won’t make much sense to you but here goes. This is the way we install an app. Note that adb is abstracted into it’s own class to make tests easier to write.
@adb = AppiumAndroid::LocalAdb.new apm.device_uuid
log.info 'Pushing large app. This can take a while (90+ sec)'
# Can't use Appium's push, results in broken pipe error
@adb.command "push #{settings.large_apk} #{DEVICE_APK}"