6

I am getting this exception on running an Appium test. The test fails at PageFactory with the exception below.

My POM:
<?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>com.telepathy.test</groupId>
    <artifactId>twitter</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>7.2.0</version>
        </dependency>
    </dependencies>

</project>

  • This was working fine up until yesterday, my machine got restarted and this error started coming.
  • Already tried with latest version of Appium (7.5.1)
  • Did mvn clean and refresh, update

Fails here: PageFactory.initElements(new AppiumFieldDecorator(this.driver), this);

java.lang.RuntimeException: java.lang.NoSuchMethodException: 
    jdk.proxy2.$Proxy9.proxyClassLookup()
    at  ​io.appium.java_client.pagefactory.bys.builder.AppiumByBuilder.prepareAnnotationMethods(
ApiumByBuilder.java:84)
Sheetal
  • 63
  • 1
  • 5

5 Answers5

7

Check the version of Java you are using. I downgraded from JDK v16 to v15.0.2 and that fixed the problem.

3

I also faced same issue but was not getting any solution for it. Just check you are using AppiumDriver instead of AndroidDriver. & You are using @FindBy annotation instead of @AndroidFindBy in your page object class. Also use PageFactory.initElements(driver, this); instead of PageFactory.initElements(new AppiumFieldDecorator(driver), this); This worked for me. It it works for you kindly acknowledge here. Thanks

ouflak
  • 2,458
  • 10
  • 44
  • 49
1

You have to rebuild your project on java version 1.8 (which will be the minimum version), then you will have to insert your jre and jdk for version 15 or less and it should be fixed.

Gilbert
  • 2,699
  • 28
  • 29
0

I was getting same error but when I am running locally via eclipse it was working fine but when I am running via command line it was failing then I have added compile version in build i.e. gradle in my case. Similarly you can add in maven also it will solve the problem.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
vinay
  • 1
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 20 '22 at 18:52
0

For me the issue got resolved by following below steps--

  1. Check the versions of maven dependencies - java version - 1.8, Appium-java-client: 7.6.0, selenium-java: 3.141.59, Testng: 7.5

  2. Update JDK compliance level to JavaSE 11 <= JavaSE15 (Click on project > Windows > Preference > click on Java compiler (left panel) > Click on the dropdown to change JavaSE16 to JavaSE11 > Apply & close )

  3. Initialize the Pagefactory as below:

    enter image description here

Note: Replace all the AndroidElement occurences to MobileElement like in base class, page & test classes.

If this answer is useful to you, kindly Upvote. :)

Priyanka B
  • 101
  • 9