please look into the below code as i am trying to automate the native android app ie Policybazaar.apk with below code written in selenium+appium
Problem is that app get launch but not able to click on login button.
package policybazaar;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.*;
public class Policylogin {
AppiumDriver driver;
@BeforeClass
public void setUp() throws MalformedURLException {
// Set up desired capabilities and pass the Android app-activity and
// app-package to Appium
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.VERSION, "5.1.1");
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"V00776140945009");
capabilities.setCapability(MobileCapabilityType.APP_PACKAGE,"com.policybazaar"); // This is package name of your app (you
// can get it from apk info app
capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY,"com.policybazaar.login.Splash_DashBoard");
// This is Launcher activity of your app (you can get it from apk info app)
// Create AndroidDriver instance and connect to the Appium server.
// It will launch the Calculator App in Android Device using the
// configurations specified in Desired Capabilities
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
}
@Test
public Policylogin() throws Exception {
// locate the Text on the policybazaar by using By.name()
WebElement Login = driver.findElement(By.id("com.policybazaar:id/dashboard_profile"));
Login.click();
}
I got it working using next code