0
votes

I am new to appium, After starting the appium server, I tried to run my simple program of opening whatsapp using the below code but I am ending with the error "Bad app".

public class WatsApp {
    public static void main(String[] args) throws MalformedURLException {
        File app = new File("‪E:\\appium\\APK files\\com.whatsapp.apk");
        WebDriver dr;
        DesiredCapabilities cap = DesiredCapabilities.android();
        cap.setCapability(CapabilityType.BROWSER_NAME, "");
        cap.setCapability("deviceName", "SM-N750");
        cap.setCapability("platformVersion", "4.4.2");
        cap.setCapability("platformName", "Android");
        cap.setCapability("app", app.getAbsolutePath());
        dr= new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), cap);
        dr.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        dr.quit();
    }
}

error: Failed to start an Appium session, err was: Error: Bad app: E:\appium\appium_work\basicappium\‪E:\appium\APK files\com.whatsapp.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'E:\appium\appium_work\basicappium\‪E:\appium\APK files\com.whatsapp.apk' info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : platform, version info: [debug] No appActivity desired capability or server param. Parsing from apk. info: [debug] No appPackage desired capability or server param. Parsing from apk. info: [debug] Using local app from desired caps: E:\appium\appium_work\basicappium\‪E:\appium\APK files\com.whatsapp.apk info: [debug] Got configuration error, not starting session info: [debug] Cleaning up appium session info: [debug] Error: Bad app: E:\appium\appium_work\basicappium\‪E:\appium\APK files\com.whatsapp.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat 'E:\appium\appium_work\basicappium\‪E:\appium\APK files\com.whatsapp.apk' at [object Object]. (C:\Program Files\Appium\node_modules\appium\lib\devices\android\android-common.js:56:13) at C:\Program Files\Appium\node_modules\appium\lib\devices\device.js:82:16 at Object.oncomplete (fs.js:107:15)

plz help me out for this thanks in advance

3
path variable setting is fine, by typing "android" in cmd prompt sdk opens up, by typing "adb" it is showing the details about the device.Roshan
i am using windows 10 and appium version 1.4.13.1Roshan

3 Answers

1
votes

Use this

String appPath = "‪E:\\appium\\APK files\\com.whatsapp.apk";
cap.setCapability("app", appPath ); \\ I am assuming there is such a capability and you know about it
1
votes

try this .....

 String apkpath="D:\\latest Android Apps\\Test.apk";
    File app=new File(apkpath);
capabilities.setCapability("app", app.getAbsolutePath());

Hope it will work :)

0
votes

Did you try with any other apk , might be your 'com.whatsapp.apk' is corrupted.

If you keep spaces in between directory name, appium UI application will throw an error. Programmatically its not an issue.