@Priya,
It is bit confusing to understand, whether you want to test Mobile browser testing or you are testing native app from your code.
If you want to test native app and if you know the apk file, follow below statements:
File objFile=new File("APK FilePath");
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability("deviceName", "Your device name");
capabilities.setCapability("app", objFile.getAbsolutePath());
try
{
driver=new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
catch(Exception e)
{
e.printStactTrace();
}
If you want to test native app and if you know the app package and activity names, follow below statements:
DesiredCapabilities capabilities=new DesiredCapabilities();
capabilities.setCapability("deviceName", "Your device");
capabilities.setCapability("appPackage", "Your package name");
capabilities.setCapability("appActivity", "Activity Name");
If you want Mobile browser testing, then use below code:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Testing");
capabilities.setCapability(MobileCapabilityType.PLATFORM, "ANDROID");
capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "BROWSER");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
I am bit confused of your code because you included both mobile browser params and native app params.
I am hoping above code snippet helps.
Thanks,
Uday