当前位置: 首页 > 知识库问答 >
问题:

使用Appium自动化获取错误

邢烨烨
2023-03-14

获取如下所述的错误:

"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)

进程以退出代码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();

    }

}

共有1个答案

方梓
2023-03-14

试试这个

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 amazon {
    private static AndroidDriver driver;
    public static void main(String[] args) throws MalformedURLException, InterruptedException {
           DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName", "Android Emulator");
        capabilities.setCapability("platformVersion", "4.4.2");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("app", "C:\\Users**.....your app full path\**com.amazon.mShop.android-5.2.0-APK4Fun.com.apk");
        capabilities.setCapability("appPackage", "com.amazon.mShop.android");
        capabilities.setCapability("appActivity", "com.amazon.mShop.home.HomeActivity");
        driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
        Thread.sleep(10000);
        driver.quit();

    }

}

确保程序中未使用的端口与用于启动appium的端口相同

 类似资料:
  • 我试图执行一个测试在移动设备但我有下一个错误 Chrome版本:83.04103.101 我正在寻找解决方案,但什么也没找到。

  • 我只是尝试用IOS提供的示例应用程序用appium设置IOS。 null null null null

  • 我试图推出iOS应用程序,这是开发和建立在Xcode版本7.3.1(7D1014)使用Appium自动化工具。为了启动ios应用程序,我在IOS模拟器上安装了苹果公司的根证书,方法是在模拟器上拖放证书文件。我能够手动启动应用程序,但使用appium自动化工具启动应用程序时出现问题。IOS应用程序启动时失败,我得到"nsurlerrordomer1012 iphone"。下面我附上了简单的代码来设置

  • 我在Cucumber自动化框架中使用Ruby来自动化我的Android和iOS应用程序。我正在使用Appium 1.6.4测试版,因为它支持iOS 10.2。 当Appium服务器首次在设备上安装iOS应用程序时,会出现一个警报对话框,询问是否允许通知。据我所知,使用Appium时,“自动接受器”功能目前不起作用。 我的主要问题是如何检查警报对话框是否存在,然后使用类似“查找元素”的功能按下“允许

  • WINDOWS 7 Appium:1.4.16.1来自Android Virtual Device Manager的Emulator Android APPIUM REST响应: 谢谢你让我知道。如果你想到什么可能是源头原因。 信息:[debug]错误:命令失败:c:\windows\system32\cmd.exe/s/c“c:\users\ddaunay\appdata\local\andro

  • 我最近开始研究iOS本机应用程序自动化- MAC OS 10.10.2iOS模拟器-iPhone 5s,iOS8.1 Appium 1.3.4 应用在应用商店中-我正在使用此应用商店应用的.App文件 Appium.app中的iOS设置-应用路径-为.app文件提供路径强制设备-模拟器设备 代码- 我还尝试只在代码中提供应用程序路径,但没有在appium.app中提供,我尝试使用和不使用应用程序的