Appium error with testdroid: java.lang.NoClassDefFoundError: org/openqa/selenium/internal/HasIdentity

1.9k Views Asked by At

Below code works with Appium client locally (version: 1.4.0.0) but fails with TestDroid cloud:

private static AppiumDriver<MobileElement> driver;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("testdroid_target", "Android");
capabilities.setCapability("deviceName", "Android Device");
capabilities.setCapability("testdroid_username", TESTDROID_USERNAME);
capabilities.setCapability("testdroid_password", TESTDROID_PASSWORD);
capabilities.setCapability("testdroid_project", "My Test Project");
capabilities.setCapability("testdroid_testrun", "AndroidDriver 1");
capabilities.setCapability("testdroid_device", "Nvidia Shield Tablet"); //Free  device
capabilities.setCapability("testdroid_app", fileUUID); 
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

It fails to create the AppiumDriver instance above, with exception: java.lang.NoClassDefFoundError: org/openqa/selenium/internal/HasIdentity

From Appium Log of other successful Appium TestDroid runs, I can see Apppium version is 1.4.3: "info: Welcome to Appium v1.4.3". So, my above code should have worked.

The Sample code by Testdroid uses very old version of Appium and this runs successfully:

private static AppiumDriver wd;
wd = new AppiumDriver(new URL(TESTDROID_SERVER+"/wd/hub"), capabilities);

in( https://github.com/bitbar/testdroid-samples/blob/master/appium/sample-scripts/java/src/test/java/com/testdroid/appium/android/sample/SampleAppiumTest.java )

This uses very old version of Appium Java Client-1.7.0 while my code uses 3.1.0. I want to use this new version of Appium Java client for its new features. Since TestDroid Appium version is latest, my code should have worked.

Can some one please help me with this.

1

There are 1 best solutions below

1
On BEST ANSWER

As Appium Java client version 1.3.0 is dependable on Selenium 2.46.0, you can remove the following lines from pom.xml:

   <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-api</artifactId>
        <version>2.42.2</version>
        <scope>test</scope>
    </dependency>