Appium [求助] 初学 Appium,调试运行时 testNG 报下面的错误。在线等。。

Rookie · 2016年11月29日 · 最后由 William 回复于 2016年11月29日 · 1647 次阅读

网上找的例子程序如下:

public class ContactManager {

    private  AndroidDriver  driver;

    @BeforeMethod(alwaysRun=true)
    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","AVM01");
        capabilities.setCapability("platformVersion", "1.0.3.1");
        capabilities.setCapability("app", app.getAbsolutePath());
        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);
    }

    @AfterMethod(alwaysRun=true)
    public void tearDown() throws Exception {
        driver.quit();
    }

    @Test(groups={"addContact"})
    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(1).sendKeys("10086");
        textFieldsList.get(2).sendKeys("Some@example.com");
        driver.swipe(100, 500, 100, 100, 2);
        driver.findElementByName("Save").click();
    }
}

Run As TestNG Test(TestNG 版本:6.9.13),执行不成功,报如下错误:

Exception in thread "main" java.lang.RuntimeException: Can't recognize the TestNG version on classpath. Please make sure that there's a supported TestNG version (aka. >= 6.0.0) on your project.
    at org.testng.remote.RemoteTestNG.getTestNGVersion(RemoteTestNG.java:124)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:48)

共收到 1 条回复 时间 点赞
Can't recognize the TestNG version on classpath. 

原因不是这个吗?

Rookie 关闭了讨论 11月29日 17:17
Rookie 关闭了讨论 11月29日 17:17
Rookie 关闭了讨论 11月29日 17:17
Rookie 关闭了讨论 11月29日 17:18
Rookie 关闭了讨论 11月29日 17:18
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册