Overview :-
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
- By node.js (Backend)
- By Appium.exe (Desktop UI)
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