Getting java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy5.proxyClassLookup() while executing the tests through mvn command

Hi All,

I have created the below class and Android Tests and I am running the tests on Google Pixel Emulator.
While running the tests via TestNG , I am able to run the tests. But while running the tests via command “mvn test” . I am getting the below exception at line: PageFactory.initElements(new AppiumFieldDecorator(driver), this);

Exception : java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy5.proxyClassLookup()

Please help.

PS: I am new to this forum and let me know if more details are required.

Regards,
Gaurav

1 Like

We do not have your other code.
Maybe helps you Find element in bottom of screen

Did you find a solution im getting the same thing?

<properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
    <aspectj.version>1.8.10</aspectj.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.4.0</version>
    </dependency>
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>7.5.1</version>
    </dependency>
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-testng</artifactId>
        <version>2.14.0</version>
    </dependency>
    <dependency> 
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
    </dependency>
    <dependency>
        <groupId>com.github.javafaker</groupId>
        <artifactId>javafaker</artifactId>
        <version>1.0.2</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <argLine>
                    -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                </argLine>
                <testFailureIgnore> false </testFailureIgnore>
                <suiteXmlFiles>
                    <suiteXmlFile>/Users/adambethlehem/IdeaProjects/Appium/testng.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

It Works when running dirrectly from testng xml file
JAVA:1.8

@Test
public void RegisterUser(){
    footerComponent footer = new footerComponent(driver);
    footer.clickAccount();
    AccountLandingPage accountLandingPage = new AccountLandingPage(driver);
    accountLandingPage.clickCreateAccount();
    RegisterPage registerPage = new RegisterPage(driver);
    registerPage.registerUser();
}

package Pages.common;

import Pages.base.BasePage;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.pagefactory.AndroidFindBy;

public class footerComponent extends BasePage {

public footerComponent(AppiumDriver driver) {
    super(driver);
    this.driver = driver;
}

@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Account\")")
public MobileElement accountBtn;

@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Search\")")
public MobileElement searchBtn;

@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Inbox\")")
public MobileElement inboxBtn;

@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Calendar\")")
public MobileElement calendarBtn;

public void clickAccount() {
    accountBtn.click();
}

public void clickSearch() {
    searchBtn.click();
}

public void clickInbox() {
    inboxBtn.click();
}

public void clickCalendar() {
    calendarBtn.click();
}
}

package Pages.Account;

import Pages.base.BasePage;
import com.github.javafaker.Faker;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.qameta.allure.Step;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions;

import java.util.UUID;

public class RegisterPage extends BasePage {
Faker faker = new Faker();

public RegisterPage(AppiumDriver<MobileElement> driver) {
    super(driver);
}

@AndroidFindBy(uiAutomator = "new UiSelector().text(\"First Name\")")
public MobileElement firstName;
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Last Name\")")
public MobileElement lastName;
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Email Address\")")
public MobileElement email;
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Mobile Number\")")
public MobileElement mobileNumber;
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Password\")")
public MobileElement password;
@AndroidFindBy(id = "com.getmyboat_v1:id/createAccountButton")
public MobileElement createAccountBtn;
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Accept\")")
public MobileElement acceptBtn;
@AndroidFindBy(id = "com.getmyboat_v1:id/marketingConsentNo")
public MobileElement noMarketing;
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Browse by trip type\")")
public MobileElement header;
@AndroidFindBy(uiAutomator = "new UiSelector().text(\"Skip\")")
public MobileElement skipBtn;

@Step("Enter First Name")
public void enterFirstName() {
    firstName.sendKeys(faker.name().firstName());
}

@Step("Enter Last Name")
public void enterLastName() {
    lastName.sendKeys(faker.name().lastName());
}

@Step("Enter Email")
public void enterEmail() {
    UUID uuid = UUID.randomUUID();
    email.sendKeys("adam+test-" + uuid + "@testmyboat.com");
}

@Step("Enter First Name")
public void enterMobile() {
    mobileNumber.sendKeys("+27829554334");
}

@Step("Enter Password")
public void enterPassword() {
    password.sendKeys("password");
}

@Step("Select No Marketing")
public void noMarketing() {
    noMarketing.click();
}

@Step("Click Accept")
public void clickAccept() {
    acceptBtn.click();
}
@Step("Click Skip")
public void clickSkip() {
    skipBtn.click();
}

@Step("Create Account")
public void clickCreateAccount() {
    createAccountBtn.click();
}

@Step("Register User")
public void registerUser() {
    enterFirstName();
    enterLastName();
    enterEmail();
    enterMobile();
    enterPassword();
    noMarketing();
    clickCreateAccount();
    clickAccept();
    clickSkip();
    wait.until(ExpectedConditions.visibilityOf(header));

}

}

Hi,

Any solution for this, I’m also facing same issue. Please help

Maybe you use java 17 or higher… there is issue for page object init elements. Move to java 11.

1 Like

@Aleksei thank you it worked, I moved from jdk 17 to 11.

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

Hello All,

I was also getting same error. I observe that local execution was working fine but when i am running with gradle it was failing stating no such method error. so i tried adding compile version in build.gradle after that issue is solved. so similary you can try on maven also.

Hope this will help you.

Thanks