Appium配置Java

Appium配置Java,appium,appium-android,Appium,Appium Android,我正在尝试使用Appium自动化我的应用程序,但我似乎无法正确配置 Appium服务器正在127.0.0.1:4723上运行并已启动。我使用带有avd.Im的Android SDK仿真器模拟一个设备,使用Eclipse和Selenium以及TestNG来测试我的配置 我得到的是@before方法中的一个错误 FAILED CONFIGURATION: @BeforeMethod setUp java.lang.NoClassDefFoundError: org/openqa/selenium/l

我正在尝试使用Appium自动化我的应用程序,但我似乎无法正确配置

Appium服务器正在127.0.0.1:4723上运行并已启动。我使用带有avd.Im的Android SDK仿真器模拟一个设备,使用Eclipse和Selenium以及TestNG来测试我的配置

我得到的是@before方法中的一个错误

FAILED CONFIGURATION: @BeforeMethod setUp
java.lang.NoClassDefFoundError: org/openqa/selenium/logging/LoggingHandler
有什么建议我的配置可能有什么问题吗

package xxx_appium.xxx_appium_test;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.aspectj.lang.annotation.Before;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.service.DriverCommandExecutor;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

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

public class ConnectionTest {

@BeforeMethod
public void setUp() throws MalformedURLException {

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("BROWSER_NAME", "Android");
    capabilities.setCapability("avd","ANexus");
    capabilities.setCapability("deviceName", "ANexus");
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("platformVersion", "9");
    capabilities.setCapability("app", 
    "C:\\Users\\xxx\\Downloads\\yyyy.apk");

    driver = new AndroidDriver<WebElement>(new         
    URL("http://localhost:4723/wd/hub"), capabilities);

}
@AfterMethod
public void tearDown() {
    driver.quit();
}

@Test
public void sampleTest() {
}
包装xxx_appium.xxx_appium_测试;
导入java.net.MalformedURLException;
导入java.net.URL;
导入java.util.ArrayList;
导入java.util.List;
导入java.util.Random;
导入org.aspectj.lang.annotation.Before;
导入org.openqa.selenium.By;
导入org.openqa.selenium.Dimension;
导入org.openqa.selenium.Point;
导入org.openqa.selenium.WebDriver;
导入org.openqa.selenium.WebElement;
导入org.openqa.selenium.remote.DesiredCapabilities;
导入org.openqa.selenium.remote.service.DriverCommandExecutor;
导入org.testng.annotations.AfterMethod;
导入org.testng.annotations.BeforeMethod;
导入org.testng.annotations.Test;
导入io.appium.java_client.AppiumDriver;
导入io.appium.java_client.MobileElement;
导入io.appium.java_client.android.AndroidDriver;
公共类连接测试{
@预处理法
public void setUp()引发畸形的DurException{
DesiredCapabilities=新的DesiredCapabilities();
setCapability(“浏览器名称”、“安卓”);
能力。设置能力(“avd”、“ANexus”);
能力。设置能力(“deviceName”、“ANexus”);
能力。设置能力(“平台名”、“安卓”);
能力。设置能力(“平台版”、“9”);
setCapability(“应用程序”,
“C:\\Users\\xxx\\Downloads\\yyyy.apk”);
驱动程序=新的AndroidDriver(新的
网址(“http://localhost:4723/wd/hub(能力),;
}
@后置法
公共无效拆卸(){
driver.quit();
}
@试验
公共无效样本测试(){
}
这里还有maven依赖项,因此您知道我使用jUnit的库在其中,因为我也尝试过使用jUnit:

<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>
    <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>6.1.0</version>
</dependency>
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.14.0</version>
</dependency>
</dependencies>

朱尼特
朱尼特
3.8.1
测试
org.testng
testng
6.14.3
测试
木卫一
java客户端
6.1.0
org.seleniumhq.selenium
硒爪哇
3.14.0

您可以尝试两件事

  • 尝试使用selenium 2.53版

    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>2.53.0</version>
    </dependency>
    

  • 工作起来很有魅力。问题是selenium版本。我不知道是什么变化如此之大,以至于我的配置在3.x版上中断,但2.53版可以工作。我遇到了同样的错误,我只需要更改selenium Java版本。我还提到了浏览器名称,通过查看您的评论,我已经删除了它,但它要求定义一个浏览器名称所以它需要。
     capabilities.setCapability("BROWSER_NAME", "Android");