Oct 24, 2017

Mobile Browser Automation with Appium on Android Real Device

Overview :-


Appium is an open source test automation tool for mobile applications. It allows you to test all the three types of mobile applications: native, hybrid and mobile web.It also allows you to run the automated tests on actual devices, emulators and simulators.

If you want to start mobile automation on Android device/emulator, first you must need to setup the Android SDK on your machine and set the paths in environment variables.Then you can attach the device and run on it.

Pre-requisites :-


1. JDK installation

2. Android SDK installation and Set Paths in Environment variables

3. Appium installation

Prerequisted Jars:

  • java-client.jar - For Appium
  • selenium-server-standalone.jar - For Webdriver capabilities
  • commons-validator.jar -  if want to run appium server programatically


Example : 


To run your test on android emulator browser, you have to pass the desire capabilities to the appium driver. If chrome browser is installed in the device, pass Browser_Name as "Chrome" or pass "Browser" to run on default browser. Before execute this program make sure appium server is running on your machine.

public class WebTest {

static AppiumDriver driver;

public static void main(String[] args) throws InterruptedException {

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName", "android");
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "Chrome");
    capabilities.setCapability(CapabilityType.VERSION, "8.0");
    capabilities.setCapability("platformName", "android");
    try {
driver = new AndroidDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
    driver.get("https://www.google.co.in");
    driver.findElement(By.name("q")).sendKeys("Welcome");
    System.out.println("done");
}
}

No comments:

Post a Comment

Mobile App Automation with Appium on Android Emulator/Device

Overview :- Appium  is an open source test automation tool for mobile applications. It allows you to test all the three types of mobile...