1)
Run the setup using the below
provided location using the URL as :
2)
Agree to the terms of service
and licence from google and download the installer.
5)
Set ANDROID_HOME as environment
variable providing the path for the SDK till the SDK path
6)
Set the path for platform tools
and tools folder specifically like below :
D:\Mobiletesting\MobileSDK\sdk\platform-tools;D:\Mobiletesting\MobileSDK\sdk\tools;
7)
Once the path for tools and
platform-tools is set check if the configurations are correct by opening the
command prompt and entering the command as
adb devices
If the configurations are correct then the device will
be listed as a result of the response for command as above in the screen.
List of devices attached
ZX1B32DBJ3
device
Here ZX1B32DBJ3
is the device connected to the 32 bit machine having SDK setup.
8)
Have an apk file of the
application to be tested ready and open appium.exe by running the utility for
launching the appium window.
9)
Configure Appium like in the
below screenshot :
Application path: Path for the apk file to be tested.
Other fields such as package,launch activity platform
version ,automation name,device name all fields will be populated by default.
Click on start the appium node server button at the
right corner of the window and we can see the below mentioned activity listed
when the server is launched.
Create a java project using the Android eclipse toolkit
and set the properties such as below.
package
com.testng;
import io.appium.java_client.AppiumDriver;
import
java.io.File;
import java.net.MalformedURLException;
import
java.net.URL;
import
java.util.concurrent.TimeUnit;
import
org.junit.AfterClass;
import
org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import
org.openqa.selenium.remote.DesiredCapabilities;
import
org.openqa.selenium.remote.RemoteWebDriver;
import
org.testng.annotations.Test;
public class WhatsApp {
WebDriver dr;
@Test
public void testApp()
throws Exception
{
//WebDriver dr;
String contact ="shreekantpandey@gmail.com";
File app = new File("D:\\Mobiletesting\\WhatsApp.apk");
DesiredCapabilities capabilities = new
DesiredCapabilities();
capabilities.setCapability("browserName","Chrome");
capabilities.setCapability("deviceName","ZX1B32DBJ3");
capabilities.setCapability("platformVersion","4.4");
capabilities.setCapability("platformName", "Android");
//capabilities.setCapability("app",app.getAbsolutePath());
//capabilities.setCapability("appPackage","com.testng");
//capabilities.setCapability("appActivity","com.testng.WhatsApp");
dr= new
RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
dr.manage().timeouts().implicitlyWait(50,
TimeUnit.SECONDS);
dr.get("http://www.apple.com");
dr.quit();
}
@AfterClass
public void
teardown(){
//close the app
dr.quit();
}
}
Where
details specific to device and platform are :
DesiredCapabilities
capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName","Chrome");
capabilities.setCapability("deviceName","ZX1B32DBJ3");
capabilities.setCapability("platformVersion","4.4");
capabilities.setCapability("platformName", "Android");
and
driver are :
dr= new
RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
dr.manage().timeouts().implicitlyWait(50,
TimeUnit.SECONDS);
Once we have the
browser handle we can navigate to any page of our choice like the content here
being navigated to
dr.get("http://www.apple.com");
___________________________________________________
2. For Android application related project
creation having a launching activity are:
package com.testng;
import
io.appium.java_client.AppiumDriver;
import java.io.File;
import java.net.URL;
import
java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.junit.AfterClass;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import
org.testng.annotations.AfterTest;
import
org.testng.annotations.BeforeMethod;
import
org.testng.annotations.Test;
import
org.openqa.selenium.support.ui.ExpectedConditions;
import
org.openqa.selenium.support.ui.WebDriverWait;
public class NewClass {
WebDriver dr =null;
@BeforeMethod
public void setup() throws
Exception
{
File appDir = new
File("D://Mobiletesting");
File app = new File(appDir,
"MakeMyTrip_Flights_Hotels_Bus.apk");
DesiredCapabilities capabilities = new
DesiredCapabilities();
capabilities.setCapability("app-package",
"com.makemytrip");
capabilities.setCapability("app-wait-activity",
"com.mmt.ui.activity.Splashactivity");
capabilities.setCapability("app-activity",
"com.mmt.ui.activity.Splashactivity");
capabilities.setCapability("deviceName","ZX1B32DBJ3");
capabilities.setCapability("platformVersion","4.4");
capabilities.setCapability("platformName",
"Android");
//capabilities.setCapability("browserName","Chrome");
//capabilities.setCapability("app-activity","com.mmt.ui.activity.Splashactivity");
// capabilities.setCapability("app",app.getAbsolutePath());
// capabilities.setCapability("appPackage","com.makemytrip");
dr=
new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),
capabilities);
dr.manage().timeouts().implicitlyWait(100,
TimeUnit.SECONDS);
}
@Test
public void loginTest() throws
Exception {
String
text;
Thread.sleep(5000);
dr.findElement(By.className("android.widget.Button")).click();
dr.findElement(By.id("com.makemytrip:id/login_activity_emailId_edt")).sendKeys("shreekant1282@gmail.com");
dr.findElement(By.id("com.makemytrip:id/login_activity_password_edt")).sendKeys("3093005");
//dr.findElement(By.id("id/login_activity_password_edt")).sendKeys("3093005");
dr.findElement(By.id("com.makemytrip:id/login_activity_login_btn")).click();
WebDriverWait wait = new
WebDriverWait(dr,80);
text = dr.findElement(By.className("android.widget.TextView")).getText();
if (text.equals("User not valid!"))
{
System.out.println("test passed");
}
else
{
System.out.println("test failed");
}
//dr.quit();
}
@AfterTest
public void teardown(){
//close the app
dr.quit();
//dr.close();
}
}
Where details are for same device
but with different .apk file having different launching activity as in the
screenshot below.
Sample makemytrip.apk file can be
downloaded from anywhere over the internet.