我正在尝试使用 Eclipse 氧气运行我的第一个 appium 测试用例。我一步一步地跟进教程
http://www.automationtestinghub.com/appium-tutorial/
我的实际代码是
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class AppiumTest {
public static void main(String[] args) {
//Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "SM-T211");
caps.setCapability("udid", "41022b138d311100"); //Give Device ID of your mobile phone
caps.setCapability("platformName", "Android");
caps.setCapability(CapabilityType.VERSION, "4.4.2");
caps.setCapability("appPackage", "com.isinolsun.app");
caps.setCapability("appActivity", "com.isinolsun.app.activities.OnBoarderActivity");
caps.setCapability("noReset", "true");
//Instantiate Appium Driver
try {
AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);
driver.closeApp();
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
}
}
我正在使用真实设备。
Appium 桌面应用程序已安装。当我运行程序时,它在那条线上给了我异常
AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);
driver.closeApp();
} catch (MalformedURLException e) {
System.out.println(e.getMessage());
}
异常消息是
Exception in thread "main" java.lang.NoClassDefFoundError: javax/websocket/DeploymentException
at io.appium.java_client.android.ListensToLogcatMessages.<clinit>(ListensToLogcatMessages.java:34)
at com.appiumtest.firsttestscript.AppiumTest.main(AppiumTest.java:27)
Caused by: java.lang.ClassNotFoundException: javax.websocket.DeploymentException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
根据教程步骤包含所有 jar 文件。sdk, android studio, jdk 也加入了。
谁能指导我?