Getting class not found error while running automation on real device in selendroid mode

StackOverflow https://stackoverflow.com//questions/24038943

  •  21-12-2019
  •  | 
  •  

Pregunta

I was trying to run automation on appium 1.1.0 but not able to start automation due to below error. I tried to run automation on real device using selendroid mode on appium.

Below are the steps which i performed during automation:

  1. Started Selendroid server
  2. Started Appium server which points to port on which selendroid server is running
  3. Started automation using Maven

Selendroid server:

XXXXX+ 14000  2480  0 18:30 pts/0    00:00:01 java -jar /home/XXXXXX/Selendroid/selendroid-standalone-0.10.0-with-dependencies.jar -aut /home/XXXXX/Selendroid/en-android.apk -selendroidServerPort 9001

Appium Server:

XXXXX+ 14001  2480  0 18:30 pts/0    00:00:01 node /home/XXXXXX/.linuxbrew/bin/appium -q -p 6001 -bp 4001 -U cff19ff1e200dbe --selendroid-port 9001

Automation started using Maven:

mvn clean install -Dappium_port=6001

Appium Capabilities:

    private static String url = "http://localhost:"
            + System.getProperty("appium_port") + "/wd/hub";
    private AppiumDriver driver;
    private static DesiredCapabilities capabilities;

    public void setUpCapabilities() throws Exception {
        capabilities = new DesiredCapabilities();
        File app = new File("en-android.apk");
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("automationName", "Selendroid");
        capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("appActivity", ".gui.StartActivity");
        capabilities.setCapability("appPackage","test");     
    }

   public AppiumDriver automationInit() throws Exception {
        driver = new AppiumDriver(new URL(url), capabilities);
        return driver;
    }

Stack trace:

java.lang.NoClassDefFoundError: org/apache/http/conn/SchemePortResolver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    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 io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:41)
    at test.utils.TestUtility.automationInit(TestUtility.java:40)

Please guide me how to resolve this issue? Is anything wrong in appium capabilities while running tests on real devices?

Thanks,

Priyank Shah

¿Fue útil?

Solución

I think this has to do with your imports on the project. "org/apache/http/conn/SchemePortResolver" is missing in a jar. Possibly due to something in appium needing it. I would suggest switching to a maven project and keeping a pom.xml that looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>ProjectName</groupId>
<artifactId>ProjectName</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.42.1</version>
    </dependency>
    <dependency>
        <groupId>io.selendroid</groupId>
        <version>0.9.0</version>
        <artifactId>selendroid-standalone</artifactId>
    </dependency>
    <dependency>
        <groupId>io.selendroid</groupId>
        <version>0.9.0</version>
        <artifactId>selendroid-client</artifactId>
    </dependency>
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>1.3.0</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.3.1</version>
    </dependency>
</dependencies>

</project>

Once you sync the project correctly and let maven import the jars you should not see these types of problems. IntelliJ does most of the work and highly recommend that IDE for doing this

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top