package com.sample;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.android.AndroidDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
@Test
public class AppiumExampleTest {
WebDriver driver ;
public void aSa() throws MalformedURLException{
File appDir = new File("/Users/siva/git");
File app = new File(appDir, "Sample.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("BROWSER_NAME","Android");
capabilities.setCapability("VERSION","Android");
capabilities.setCapability("device","Android");
//mandatory capabilities
capabilities.setCapability("deviceName","Android");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage", "com.****.***");
capabilities.setCapability("appActivity", "com.jhonsoned.aqua.login.viewcontroller.LoginActivity");
//other caps
capabilities.setCapability("app", app.getAbsolutePath());
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
}
Note :
AppActivty and appPackge will come automatically once u have chosen path in Appium server
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import org.junit.After;
import org.junit.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.android.AndroidDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
@Test
public class AppiumExampleTest {
WebDriver driver ;
public void aSa() throws MalformedURLException{
File appDir = new File("/Users/siva/git");
File app = new File(appDir, "Sample.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("BROWSER_NAME","Android");
capabilities.setCapability("VERSION","Android");
capabilities.setCapability("device","Android");
//mandatory capabilities
capabilities.setCapability("deviceName","Android");
capabilities.setCapability("platformName","Android");
capabilities.setCapability("appPackage", "com.****.***");
capabilities.setCapability("appActivity", "com.jhonsoned.aqua.login.viewcontroller.LoginActivity");
//other caps
capabilities.setCapability("app", app.getAbsolutePath());
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
}
Note :
AppActivty and appPackge will come automatically once u have chosen path in Appium server
Free SEO Tips and Tricks
ReplyDelete