File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "/build/outputs/apk/");
File  = new File(appDir, "-debug.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("-version", "1.0");
capabilities.setCapability("platformName", "");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "Your package name");
capabilities.setCapability("appActivity", "MainActivity");


Line 1: Get the to your Project’s Root Directory
O/P: classPathRoot: /Users/john.doe/AppiumProject/app

Line 2: Append the Path to the Directory of the folder where your “.apk” is placed, with the Project’s Root Directory.
O/P: classPathRoot: /Users/john.doe/AppiumProject/app/build/outputs/apk/

Line 3: Append your “.apk” file name, with the Project’s Root Directory(till your apk folder).
O/P: classPathRoot: /Users/john.doe/AppiumProject/app/build/outputs/apk/apk-debug.apk

Line 4 and onwards: Initiate Desired capabilitieas and them as per your platform and device

Source link


Please enter your comment!
Please enter your name here