TestProject Forum

io.cucumber.core.exception.CucumberException: Failed to instantiate class

I’m trying to use io.testproject with cucumber and pagefactory my but when i initElements i get this error.

When i debug my the test this stop in PageFactory.initElements(new AppiumFieldDecorator(driver), this);

@IOS
Scenario Outline: Primera prueba                                                        # src/test/resources/features/Surgerys/CreateSurgeryWothoutTag.feature:13
  Given A app that the user make the Login with "copleyrep1@gmail.com" y "Limelight#1". # testproject.steps.Login.LoginSteps.aAppTheUserMakeTheLoginWithY(java.lang.String,java.lang.String)
      io.cucumber.core.exception.CucumberException: Failed to instantiate class testproject.steps.Login.LoginSteps
    at io.cucumber.core.runtime.ObjectFactoryServiceLoader$DefaultJavaObjectFactory.cacheNewInstance(ObjectFactoryServiceLoader.java:149)

┌───────────────────────────────────────────────────────────────────────────────────┐
│ Share your Cucumber Report with your team at https://reports.cucumber.io          │
│ Activate publishing with one of the following:                                    │
│                                                                                   │
│ src/test/resources/cucumber.properties:          cucumber.publish.enabled=true    │
│ src/test/resources/junit-platform.properties:    cucumber.publish.enabled=true    │
│ Environment variable:                            CUCUMBER_PUBLISH_ENABLED=true    │
│ JUnit:                                           @CucumberOptions(publish = true) │
│                                                                                   │
│ More information at https://reports.cucumber.io/docs/cucumber-jvm                 │
│                                                                                   │
│ Disable this message with one of the following:                                   │
│                                                                                   │
│ src/test/resources/cucumber.properties:          cucumber.publish.quiet=true      │
│ src/test/resources/junit-platform.properties:    cucumber.publish.quiet=true      │
└───────────────────────────────────────────────────────────────────────────────────┘

I have this Files LoginSteps.java which is the one that manages my cucumber steps for the login

public class LoginSteps extends BaseSteps {

    public final LoginPage loginPage = new LoginPage(driver);
}

BaseSteps.java

public class BaseSteps {

    public MobileDriver driver = BaseDriver.getDriver();
    public WaitHelpers waitHelpers = new WaitHelpers();
}

LoginPage.java

public class LoginPage extends BasePage {

    public LoginPage(MobileDriver driver) {
        super(driver);
    }

}

BasePage.java

public class BasePage extends Helpers {

    protected MobileDriver driver = null;
    protected WebDriverWait waiter = null;

    public BasePage(MobileDriver driver) {
        this.driver = driver;
        this.waiter = new WebDriverWait(driver, 60);
        PageFactory.initElements(new AppiumFieldDecorator(driver), this);
    }

    @Override
    public MobileDriver getDriver() { return this.driver; }

    @Override
    public WebDriverWait waiter() { return this.waiter; }

}

I follow this document.

This are my cucumberOptions

@CucumberOptions(
        features = "src/test/resources/features",
        glue = { "testproject"},
        monochrome = true,
        tags = "@IOS",
        plugin = {"pretty", "html:target/cucumber/", "json:target/report/cucumber.json",
                "junit:target/report/cucumber.xml, io.testproject.sdk.internal.reporting.extensions.cucumber.CucumberReporter"}
)

Thanks.

@iptqa.automation

Can you please place it in a try/catch around this and run again to see the exact exception?

Also, please make sure that a simple example such as this one for using the Cucumber plugin works well for you: