My code is as below and I have also configured all the configuration:
package Appium_Demo;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
//import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.By;
//import org.openqa.selenium.remote.RemoteWebDriver;
//import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
//import io.appium.java_client.android.*;
@Test
public class Demo1
{
public AppiumDriver driver;
//WebDriver driver;
@BeforeTest
public void setup() throws MalformedURLException
{
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot,"/app");
File app = new File(appDir, "AudibleGreetings_23Mar2016.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("automationName", "Appium");
//capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
capabilities.setCapability("devicename", "Nexus_TEST");
capabilities.setCapability("platformversion", "6.0.1");
capabilities.setCapability("platformname", "ANDROID");
//capabilities.setCapability("appium-version", "2.1.0");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appackage", "com.app.subinpara");
capabilities.setCapability("appActivity", "com.app.subinpara.SplashActivity");
capabilities.setCapability("appWaitActivity", "com.app.subinpara.login.LoginActivity");
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"),capabilities);
}
public void FirstTest()
{
driver.findElement(By.id("android.widget.TextView")).click();
driver.findElement(By.id("com.android.launcher3:id/icon")).click();
driver.findElement(By.id("com.app.subinpara:id/et_email")).sendKeys("tarun.patel@etatvasoft.com");
driver.findElement(By.id("com.app.subinpara:id/et_password")).sendKeys("tatva123");
driver.findElement(By.id("com.app.subinpara:id/btnLogin")).click();
}
@AfterTest
public void LastTEST()
{
driver.closeApp();
}
}