在android eclipse中执行代码时显示以下错误
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:65)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:55)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:99)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:153)
at apps.testapp.main(testapp.java:34)
Caused by: java.lang.RuntimeException: Stub!
at org.apache.http.conn.ssl.AbstractVerifier.<init>(AbstractVerifier.java:5)
at org.apache.http.conn.ssl.AllowAllHostnameVerifier.<init>(AllowAllHostnameVerifier.java:5)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:124)
... 6 more
这里是我的代码..
public class testapp
{
public static void main(String...arf)
{
//File app = new File("appiumAndroid.apk");
//System.out.println(app.getAbsolutePath());
//System.out.println(""+test());
DesiredCapabilities capabilities = new DesiredCapabilities();
//capabilities.setCapability("app",app.getAbsolutePath());
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("platformVersion", "4.4.2");
capabilities.setCapability("platformName", "Android");
//capabilities.setCapability("app",app.getAbsolutePath());
capabilities.setCapability("deviceName", "5554");
//capabilities.setCapability("device", "emulator");
capabilities.setCapability("appPackage", "com.example.appiaumdemo");
capabilities.setCapability("appActivity",".MainActivity");
try
{
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
driver.close();
}
catch(MalformedURLException e)
{
e.printStackTrace();
}
}
}
答案 0 :(得分:1)
我是Android Studio新手,我遇到了同样的问题。到目前为止我一直在使用Eclipse。检查默认项目设置/项目 - 项目SDK:显示它正在使用Android平台作为目标。切换到Java JDK允许我的Appium脚本运行。