移动测试客户端
下载(Android)


移动应用测试大赛帮助





测试报告示例







Bug报告示例






Appium配置文件示例



<?xml version="1.0" encoding="UTF-8"?>
<config>
    <value>
	<platformName>Android</platformName>
	<deviceName>Android Emulator</deviceName>
	<app>C:\Users\atian\eclipse_workspace\Appium_test\apps\tuniu.apk</app>
	<browserName></browserName>
	<platformVersion>4.3</platformVersion>
	<appPackage>com.tuniu.app.ui</appPackage>
	<appActivity>.homepage.LaunchActivity</appActivity>
	<unicodeKeyboard>true</unicodeKeyboard>
	<resetKeyboard>true</resetKeyboard>
	</value>
</config>


	

Appium测试示例


	

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
import io.appium.java_client.android.Connection;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.URL;
import java.util.List;

public class AppiumTest {

	private AndroidDriver driver;

	@Before
	public void setUp() throws Exception {

		// 读取配置文件
		Config config = new Config();
		ConfigReader configReader = new ConfigReader();
		configReader.loadconfig(config);

		// 设置自动化相关参数
		DesiredCapabilities capabilities = new DesiredCapabilities();
		capabilities.setCapability("browserName", config.getBrowserName());
		capabilities.setCapability("platformName", config.getPlatformName());
		capabilities.setCapability("deviceName", config.getDeviceName());

		// 设置安卓系统版本
		capabilities.setCapability("platformVersion", config.getPlatformVersion());
		// 设置apk路径
		capabilities.setCapability("app", config.getApp());

		// 设置app的主包名和主类名
		capabilities.setCapability("appPackage", config.getAppPackage());
		capabilities.setCapability("appActivity", config.getAppActivity());
		// 设置使用unicode键盘,支持输入中文和特殊字符
		capabilities.setCapability("unicodeKeyboard", config.getUnicodeKeyboard());
		// 设置用例执行完成后重置键盘
		capabilities.setCapability("resetKeyboard", config.getResetKeyboard());
		// 初始化
		driver = new AndroidDriver<>(new URL(config.getAppiumUrl()), capabilities);
	}

	@Test
	public void addContact() {

		// 由于启动的是.homepage.LaunchActivity,等待进入.homepage.MainFragmentActivity
		do {
			if (driver.currentActivity().equals(".homepage.MainFragmentActivity"))
				break;
		} while (true);

		// 定位到.homepage.MainFragmentActivity上的搜索框并点击,
		// 跳转至.search.global.GlobalSearchActivity
		WebElement el1 = driver.findElementByClassName("android.widget.TextView");
		el1.click();

		// 定位到EditText,输入“南京”并按回车键
		// 跳转至.search.global.GlobalSearchResultActivity
		WebElement el2 = driver.findElementByClassName("android.widget.EditText");
		el2.sendKeys("南京");

		// 判断网络连接状态
		if (driver.getConnection().equals(Connection.WIFI) 
			|| driver.getConnection().equals(Connection.DATA)) {
			driver.pressKeyCode(AndroidKeyCode.ENTER);
			// 定位第一条查询结果并点击(因为查询结果的resource_ID相同,所以用list来存储),
			// 跳转至.activity.Boss3GroupProductDetailActivity
			List imageViewsList = 
				driver.findElements(By.id("com.tuniu.app.ui:id/iv_product_small_image"));
			imageViewsList.get(0).click();
		} else {
			System.out.println("No Internet Connection!");
		}
	}

	@After
	public void tearDown() throws Exception {
		driver.quit();
	}
}