新手学习,根据http://blog.csdn.net/jiabailong/article/details/52293729AppDemo,遇到如题问题。帖子运行
查找网友所述方法:删除 .metadata,重启 eclipse 等,皆无法修正。请诸位大神帮忙看,或者介绍一套真机可行的 ubuntu 下的运行环境。不甚感谢!
AppDemo.java 没有语法错误,具体内容如下。
package com.Demo;
import io.appium.java_client.AppiumDriver;
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.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.File;
import java.net.URL;
import java.util.List;
public class AppDemo {
private AppiumDriver driver;
@Before
public void setUp() throws Exception {
// set up appium
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps");
File app = new File(appDir, "ContactManager.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("deviceName","QGSO7T75NRBUYLTK");
capabilities.setCapability("platformVersion", "7.1.1");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.example.android.contactmanager");
capabilities.setCapability("appActivity", ".ContactManager");
driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
@After
public void tearDown() throws Exception {
driver.quit();
}
@Test
public void addContact(){
WebElement el = driver.findElement(By.name("Add Contact"));
el.click();
List 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();
}
}