TA的每日心情 | 奋斗 2016-1-13 11:18 |
---|
签到天数: 2 天 连续签到: 1 天 [LV.1]测试小兵
|
使用eclipse 运行写的第一个appium 。执行提示如图的错误
导入用的jar 为
写的测试类
private AndroidDriver driver;
@Before
public void setUp() throws Exception {
//设置apk的路径
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "app");
File app = new File(appDir, "ContactManager.apk");
//设置自动化相关参数
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName", "Android Emulator");
//设置安卓系统版本
capabilities.setCapability("platformVersion", "2.2");
//设置apk路径
capabilities.setCapability("app", app.getAbsolutePath());
//设置app的主包名和主类名
capabilities.setCapability("appPackage", "com.example.android.contactmanager");
capabilities.setCapability("appActivity", ".ContactManager");
//初始化
// driver = new AndroidDriver (new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@Test
public void addContact(){
WebElement el = driver.findElement(By.name("Add Contact"));
el.click();
List<WebElement> textFieldsList = driver.findElementsByClassName("android.widget.EditText");
textFieldsList.get(0).sendKeys("Some Name");
textFieldsList.get(2).sendKeys("Some@example.com");
driver.swipe(100, 500, 100, 100, 2);
driver.findElementByName("Save").click();
}
@After
public void tearDown() throws Exception {
driver.quit();
}
麻烦各位高手指导下
|
|