Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
First Appium Test Java
package rightqa.appiumAndroidDemo;
//This is a Library for Appium Android driver
//This is a Library to create path to the application under test (APK)
//This is a Library to verify if the URL is malformed
//This is a Library to create a URL for the Appium Server
//This is a Library to configure Desired Capabilities
import org.openqa.selenium.remote.DesiredCapabilities;
public class FirstAppiumTest {
protected static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
//Path to Eclipe Project
File classpathRoot = new File(System.getProperty("user.dir"));
//This will get the path to the apps folder that holds the application under test (APK)
File appDir = new File(classpathRoot, "/apps/");
//This will get the full path to the apk file
File app = new File(appDir, "api.apk");
//Create an object for Desired Capabilities
DesiredCapabilities capabilities = new DesiredCapabilities();
//These are mandatory capabilities that define the device name and platform name. Platform name could be iOS, Android or FirefoxOS
//Some other capabilities that gets the actual app
capabilities.setCapability("app", app.getAbsolutePath());
//Initialize the driver object with the URL to Appium Server and passing the capabilities
driver = new AndroidDriver(new URL(""), capabilities);
//Just added wait so that you can see the actual app loaded in the emulator
//Quitting the driver session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.