Appium Appium+eclipse+java +android 真机 , Run As +JUnit Test 报错 An internal error occurred during: "Launching AppDemo". java.lang.NullPointerException

Yannie · 2018年01月30日 · 最后由 Yannie 回复于 2018年01月31日 · 1680 次阅读

新手学习,根据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();

}

}

共收到 2 条回复 时间 点赞

设断点,debug 下,空指针的错误

Linny 回复

谢谢。我不用 eclipse 自带的 junior test,改为 testng 了

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册