-2
獲取誤差如下所述獲取錯誤:與Appium自動化
"C:\Program Files\Java\jdk1.8.0_31\bin\java" -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:\Program Files\Android\Android Studio\bin" -Dfile.encoding=UTF-8 -classpath "D:\Appium\AndroidSDKs\platforms\android-23\android.jar;D:\Appium\AndroidSDKs\platforms\android-23\data\res;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\classes\androidTest\debug;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\classes\debug;D:\Appium\MobileAutomation\MyApplication\lib\gson-2.3.1.jar;D:\Appium\MobileAutomation\MyApplication\lib\httpmime-4.4.1.jar;D:\Appium\MobileAutomation\MyApplication\lib\commons-io-2.4.jar;D:\Appium\MobileAutomation\MyApplication\lib\guava-18.0.jar;D:\Appium\MobileAutomation\MyApplication\lib\commons-logging-1.1.3.jar;D:\Appium\MobileAutomation\MyApplication\lib\commons-exec-1.3.jar;D:\Appium\MobileAutomation\MyApplication\lib\httpcore-4.4.1.jar;D:\Appium\MobileAutomation\MyApplication\lib\selenium-java-2.47.1.jar;D:\Appium\MobileAutomation\MyApplication\lib\commons-collections-3.2.1.jar;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\exploded-aar\com.android.support\design\23.1.1\res;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\exploded-aar\com.android.support\design\23.1.1\jars\classes.jar;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\exploded-aar\com.android.support\recyclerview-v7\23.1.1\jars\classes.jar;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\exploded-aar\com.android.support\recyclerview-v7\23.1.1\res;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\exploded-aar\com.android.support\support-v4\23.1.1\jars\libs\internal_impl-23.1.1.jar;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\exploded-aar\com.android.support\support-v4\23.1.1\res;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\exploded-aar\com.android.support\support-v4\23.1.1\jars\classes.jar;D:\Appium\MobileAutomation\MyApplication\lib\hamcrest-core-1.3.jar;D:\Appium\MobileAutomation\MyApplication\lib\commons-lang3-3.4.jar;D:\Appium\MobileAutomation\MyApplication\lib\commons-codec-1.10.jar;D:\Appium\MobileAutomation\MyApplication\lib\apache-mime4j-0.6.jar;D:\Appium\MobileAutomation\MyApplication\lib\junit-4.12.jar;D:\Appium\AndroidSDKs\extras\android\m2repository\com\android\support\support-annotations\23.1.1\support-annotations-23.1.1.jar;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\res;D:\Appium\MobileAutomation\MyApplication\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\jars\classes.jar;D:\Appium\MobileAutomation\MyApplication\lib\httpclient-4.4.1.jar;D:\Appium\MobileAutomation\MyApplication\lib\java-client-3.2.0.jar;C:\Program Files\Android\Android Studio\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.example.bhaskarac.myapplication.Amazan
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:57)
at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:60)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:251)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:228)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:89)
at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:63)
at io.appium.java_client.remote.AppiumCommandExecutor.<init>(AppiumCommandExecutor.java:36)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:167)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:69)
at com.example.bhaskarac.myapplication.Amazan.main(Amazan.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
過程完成了exit code 1
。
我的計劃是:
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import io.appium.java_client.android.AndroidDriver;
public class Amazan {
private static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException, InterruptedException {
File classpathRoot = new File(System.getProperty("user.dir"));
System.out.println(classpathRoot);
File appDir = new File(classpathRoot, "/Apps/Amazon/");
File app = new File(appDir, "in.amazon.mShop.android.shopping.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("platformVersion", "4.4.2");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "in.amazon.mShop.android.shopping");
capabilities.setCapability("appActivity", "com.amazon.mShop.home.HomeActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4444/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
Thread.sleep(10000);
driver.quit();
}
}
雖然異常堆棧跟蹤和源代碼很好,如果你能提供一些關於你正在做什麼的背景信息,期望的行爲是什麼等等,那也是很好的。 –
我是新來的appium automation 。安裝android studio並嘗試在啓動appium後運行上述示例代碼。 –
確保您的appium在指定的端口4444上運行 – karthick23