Maven构建Test NG项目报错,解决方案:

FAILED CONFIGURATION: @BeforeMethod setUp
java.lang.NoClassDefFoundError:org/openqa/selenium/remote/http/W3CHttpCommandCodecatio.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:262)
Caused by:java.lang.ClassNotFoundException:org.openqa.selenium.remote.http.W3CHttpCommandCodec at java.net.URLClassLoader.findClass(UnknownSource)
网上查询解决方案:
1、在pom.xml里添加selenium-remote-driver依赖
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.4.0</version>
</dependency>
2、降低testng版本号: <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0</version>
</dependency>
3、依赖包冲突,删除多余的依赖(该方法问题解决)

备注,我删除的依赖是:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>LATEST</version>
<scope>test</scope>
</dependency>
网友评论