1.新建項(xiàng)目
2.新建module
新建一個module,選擇Java library類型荤崇。
3.配置build.gradle
在新建的module中做如下配置,引入jar包。
compile 'junit:junit:4.12'
compile files('libs/selenium-server-standalone-3.4.0.jar')
compile 'io.appium:java-client:4.1.2'
4.創(chuàng)建測試腳本
public class BaseAndroidTest {
//Driver
protected AppiumDriver<AndroidElement> driver;
/**
* 配置啟動driver
* @throws Exception
*/
@Before
public void setUp() throws Exception {
//app的目錄
File appDir = new File("/Users/.../appium/AppiumTestApplication/doumisaastest/apps");
//app的名字吹榴,對應(yīng)你apps目錄下的文件
File app = new File(appDir, "DoumiSAAS_release.apk");
//創(chuàng)建Capabilities
DesiredCapabilities capabilities = new DesiredCapabilities();
//設(shè)置要調(diào)試的模擬器的名字
capabilities.setCapability("deviceName","minote");
//設(shè)置模擬器的系統(tǒng)版本
capabilities.setCapability("platformVersion", "6.0");
capabilities.setCapability("platformName", "Android");
//設(shè)置app的路徑
capabilities.setCapability("app", app.getAbsolutePath());
//設(shè)置app的包名
capabilities.setCapability("appPackage", "com.doumi.workadmin");
//設(shè)置app的啟動activity
capabilities.setCapability("appActivity", ".activity.common.LaunchActivity");
//啟動driver
driver = new AndroidDriver<>(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
}
@After
public void tearDown() throws Exception {
//測試完畢,關(guān)閉driver滚婉,不關(guān)閉將會導(dǎo)致會話還存在图筹,下次啟動就會報錯
driver.quit();
}
/**
* 要執(zhí)行的的測試方法
*/
@Test
public void addContact(){
}
}