Java-Client 1.6.2 not instantiating AppiumDriver, receiving NoSuchMethodError

Good day,

I have been trying to update my dependencies in my project so that I can start to use the PageFactory classes that have been recently added. In this process I have somehow screwed up my Jenkins instance so that any test that runs fails with the following message:

Here are the dependencies that I have listed in my POM.xml:

  <dependencies>
  <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>2.42.2</version>
  </dependency>
  <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
  </dependency>
  <dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-server</artifactId>
  <version>2.42.2</version>
  <type>pom</type>
  </dependency>
  <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-all</artifactId>
      <version>1.3</version>
  </dependency>
  <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.2.4</version>
  </dependency>
  <dependency>
      <groupId>org.json</groupId>
      <artifactId>json</artifactId>
      <version>20080701</version>
  </dependency>
  <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-api</artifactId>
      <version>2.42.2</version>
  </dependency>
  <dependency>
  <groupId>io.appium</groupId>
  <artifactId>java-client</artifactId>
  <version>1.6.2</version>
 </dependency>
  <dependency>
      <groupId>org.uiautomation</groupId>
      <artifactId>ios-client</artifactId>
      <version>0.6.5</version>
     </dependency>
    <dependency>
      <groupId>org.uiautomation</groupId>
      <artifactId>ios-common</artifactId>
      <version>0.6.5</version>
     </dependency>
 </dependencies>

I originally thought that it may be the type of capabilities that I was setting when instantiating AppiumDriver but that turned into a rabbit hole and it seems that I am instantiating it correctly per the IOS example test in the Appium project. This is how I am instantiating:

 File app = new File(appPath + appName + ".app");
 DesiredCapabilities capabilities = new DesiredCapabilities();
 capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.IOS);
 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone Simulator");
 capabilities.setCapability(MobileCapabilityType.APP , app.getAbsolutePath());
 //Connect to the server to run test
 driver = new AppiumDriver(new URL("http://localhost:" + appiumPort + "/wd/hub"), capabilities) ;

Has anyone else encountered this? I have seen a few threads in the google group but none of the solutions presented in those have worked for me.

Thanks in advance,

Jasmine

You are probably including an old version of selenium somewhere. Any version prior to v2.42.2 is going to have that issue.

I know the proper version is in your Maven dependency list, but I’ve seen other users who had the proper setup but were still including an older version of selenium somewhere else and it was overwriting the change.

Make sure Jenkins is actually using the newest selenium library.

That’s exactly what the issue was. I found by running

mvn dependency:tree

that another dependency org.uiautomation was referencing an older version of the selenium server. Once I got rid of those dependencies and updated my code to use the regular DesiredCapabilities everything is back working great and I can implement the PageFactory update :slight_smile:

1 Like

Do we need to use MobileCapabilityType capabilities?

Can I see your pom file?

Is this a Java version issue? See this post http://stackoverflow.com/questions/7237536/exception-in-thread-main-java-lang-unsupportedclassversionerror-a-unsupporte

I am running 1.6.0_65. My Java control panel says:
Your system has the recommended version of Java.
Java 7 Update 51

The error I get when I try to instantiate AppiumDriver is:
java.lang.UnsupportedClassVersionError: io/appium/java_client/AppiumDriver : Unsupported major.minor version 51.0

SO, WHAT VERSION OF JAVA IS REQUIRED???

Solved by installing Java 1.7.0_67

2 Likes

I’m facing similar issue with IOSDriver
NoSuchMethodException: io.appium.java_client.ios.IOSDriver

I’m using webdriver v2.43.0, appium 1.3.4, appium java client- 2.1.0

did you resolved this issue? I m using java 8 and my java-client is 2.2.0 version and facing the issue as;
Exception in thread “main” java.lang.UnsupportedClassVersionError: io/appium/jav
a_client/ios/IOSDriver : Unsupported major.minor version 51.0

I’m sure you have probably seen this, but if not, here is a link to what I think may be the issue