我是Appium Android驱动程序的新手,并且在运行脚本时遇到错误消息。
下面是我的脚本:
private static AndroidDriver driver;
public static void main(String[] args) throws Exception {
File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "Com_first_app/app/release");
File app = new File(appDir, "app-release.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
//capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("deviceName", "Nexus 6");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "7.1.1");
capabilities.setCapability("browserName", "");
capabilities.setCapability("fullReset", false);
capabilities.setCapability("noReset", true);
capabilities.setCapability("app-Package", "com.example.com_first_app");
capabilities.setCapability("app-Activity", "com.example.com_first_app.Login");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(5,TimeUnit.SECONDS);
driver.findElementById("com.example.com_first_app:id/email_sign_in_button").sendKeys("test@gmail.com");
driver.findElementById("com.example.com_first_app:id/password").sendKeys("12345678");
driver.findElementById("com.example.com_first_app:id/email_sign_in_button").click();
Thread.sleep(1000);
driver.quit();
}
运行上面的脚本时,我收到以下错误消息:
线程“ main”中的异常java.lang.NoSuchFieldError:INSTANCE
在org.apache.http.conn.ssl.SSLConnectionSocketFactory。(SSLConnectionSocketFactory.java:146)
在org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
在org.openqa.selenium.remote.internal.HttpClientFactory。(HttpClientFactory.java:57)
在org.openqa.selenium.remote.internal.HttpClientFactory。(HttpClientFactory.java:60)
在org.openqa.selenium.remote.internal.ApacheHttpClient $ Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:288)
在org.openqa.selenium.remote.internal.ApacheHttpClient $ Factory。(ApacheHttpClient.java:259)
在io.appium.java_client.remote.AppiumCommandExecutor。(AppiumCommandExecutor.java:52)
在io.appium.java_client.AppiumDriver。(AppiumDriver.java:169)
在io.appium.java_client.android.AndroidDriver。(AndroidDriver.java:82)
在com.example.com_first_app.appium_login.main(appium_login.java:28)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)``
在java.lang.reflect.Method.invoke(Method.java:498)
com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)以退出代码1完成的过程