首页 新闻 会员 周边

刚刚开始学习自动化测试,运行eclipse+Appium Android测试用例eclipse一直报错。。。求大神帮忙解决

1
[待解决问题]

每次运行都报错,该导入的jar包都导入了,具体报错如下:

问题补充:

java.lang.IncompatibleClassChangeError: Class io.appium.java_client.remote.AppiumCommandExecutor$$Lambda$5/1128096251 does not implement the requested interface java.util.function.Supplier
    at java.util.Optional.orElseGet(Optional.java:267)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:100)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:42)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
    at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:38)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:83)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:93)
    at com_qppium.my_app.AppiumTestTest.setUp(AppiumTestTest.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

java.lang.NullPointerException
    at com_qppium.my_app.AppiumTestTest.tearDown(AppiumTestTest.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:36)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

smileTest的主页 smileTest | 菜鸟二级 | 园豆:202
提问于:2017-11-09 16:18
< >
分享
所有回答(2)
0

要不换成testng试试 去掉junit相关jar

ycyzharry | 园豆:25653 (高人七级) | 2017-11-10 09:10

testng你会吗?

支持(0) 反对(0) smileTest | 园豆:202 (菜鸟二级) | 2017-11-10 09:38

@smileTest: maven工程里添加依赖

 <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>6.9.4</version>
      <scope>test</scope>
  </dependency>
    
支持(0) 反对(0) ycyzharry | 园豆:25653 (高人七级) | 2017-11-10 09:41

@ycyzharry: 其实testng和Junit有什么不同?

支持(0) 反对(0) smileTest | 园豆:202 (菜鸟二级) | 2017-11-10 09:58

@smileTest: 看你报错很多都是junit 我在想是不是缺少什么jar 或者有什么冲突引起的

支持(0) 反对(0) ycyzharry | 园豆:25653 (高人七级) | 2017-11-10 11:25

@ycyzharry: 可以加QQ或微信聊吗

支持(0) 反对(0) smileTest | 园豆:202 (菜鸟二级) | 2017-11-10 11:29

@smileTest: 有问题可私信问

支持(0) 反对(0) ycyzharry | 园豆:25653 (高人七级) | 2017-11-10 13:15

@ycyzharry:用了testng还是报错啊

支持(0) 反对(0) smileTest | 园豆:202 (菜鸟二级) | 2017-11-10 17:38

@smileTest: 报错贴出来

支持(0) 反对(0) ycyzharry | 园豆:25653 (高人七级) | 2017-11-10 17:45

@ycyzharry: 

import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.android.AndroidDriver;

import java.net.URL;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class TestCalculator1 {

private AppiumDriver driver;

@BeforeClass
public void setup() throws Exception {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.BROWSER_NAME, "");
cap.setCapability("platformName", "Android"); // 指定测试平台
cap.setCapability("deviceName", "Android Emulator");// 指定测试机的ID,通过adb命令`adb devices`获取
cap.setCapability("platformVersion", "4.2.2");

// 将上面获取到的包名和Activity名设置为值
cap.setCapability("appPackage", "com.android.calculator2");
cap.setCapability("appActivity", "com.android.calculator2.Calculator");

// A new session could not be created的解决方法
cap.setCapability("appWaitActivity", "com.android.calculator2.Calculator");
// 每次启动时覆盖session,否则第二次后运行会报错不能新建session
cap.setCapability("sessionOverride", true);

driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
}

@Test
public void plus() {

// 获取1
//driver.findElementById("com.android.calculator2:id/digit1").click();
driver.findElementByXPath("//android.widget.Button[contains(@text,'1')]").click();;
// 获取+
//driver.findElementById("com.android.calculator2:id/plus").click();
driver.findElementByXPath("//android.widget.Button[contains(@text,'+')]");
// 获取2
//driver.findElementById("com.android.calculator2:id/digit2").click();
driver.findElementByXPath("//android.widget.Button[contains(@text,'2')]");
// 获取=
//driver.findElementById("com.android.calculator2:id/eq").click();
driver.findElementByXPath("//android.widget.Button[contains(@text,'=')]");
//driver.findElement(By.xpath("//*[text()=’退出’])"));

}

@AfterClass
public void tearDown() throws Exception {

driver.quit();

}

}

 

 

 

报错:

java.lang.IncompatibleClassChangeError: Class io.appium.java_client.remote.AppiumCommandExecutor$$Lambda$5/1402433372 does not implement the requested interface java.util.function.Supplier

支持(0) 反对(0) smileTest | 园豆:202 (菜鸟二级) | 2017-11-10 17:51

@smileTest: 你用的库有冲突啊 是用maven管理的还是直接加jar到build path里

支持(0) 反对(0) ycyzharry | 园豆:25653 (高人七级) | 2017-11-10 18:20

@ycyzharry: 直接加jar到buildpath里的

支持(0) 反对(0) smileTest | 园豆:202 (菜鸟二级) | 2017-11-11 10:08

@ycyzharry: 

支持(0) 反对(0) smileTest | 园豆:202 (菜鸟二级) | 2017-11-11 10:20

@smileTest: 换成maven管理库

支持(0) 反对(0) ycyzharry | 园豆:25653 (高人七级) | 2017-11-11 22:11

@ycyzharry: 怎么换

支持(0) 反对(0) smileTest | 园豆:202 (菜鸟二级) | 2017-11-13 09:44

@smileTest: 新建maven工程 在pom.xml里配置所有依赖库 

支持(0) 反对(0) ycyzharry | 园豆:25653 (高人七级) | 2017-11-13 09:46
0

UI自动化测试维护成本高,学习成本也高,建议转接口自动化测试,这里有一个低成本做接口测试的平台,无需代码,推荐给你。www.ironz.com

TianBJ | 园豆:210 (菜鸟二级) | 2020-02-26 18:26
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册