serenity-bdd / serenity-cucumber

Cucumber integration for the Serenity BDD Reporting library
Other
78 stars 74 forks source link

Step Definitions classes are using default constructor instead of parameterized ones #147

Closed UtsaChakraborty closed 6 years ago

UtsaChakraborty commented 6 years ago

Hi ,

am trying to convert a cucumber project to Serenity Cucumber one. While doing so I used the same TestContext class, page definition classes as in Cucumber. I have not included PicoContainer dependency as Serenity-cucumber dependency already takes care of the instantiation part. But while doing so

`1. the error I faced, no empty or page enable constructor so I added empty constructor to the step definition classes, but then I am unable to use the parameterized constructor and also facing the issue (JavaNullpointer exception) in Hooks class in the following step:

testContext.getWebDriverManager().getDriver();

PFB the step definition file: package stepdefinitions;

import cucumber.TestContext; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import net.thucydides.core.annotations.Steps;

import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import pageobjects.HomePage;

public class HomePageSteps { @Steps TestContext testContext ;//*** HomePage homepage;

 public HomePageSteps(TestContext context){
    this.testContext = context;
    System.out.println("context value"+context.toString());
    homepage = testContext.getPageObjectManager().getHomePage();
}
 public HomePageSteps()
 {       
    // this(context);       
     //homepage = testContext.getPageObjectManager().getHomePage();//***
 }

@Given("^: I navigate to any page in SAM AH$")
public void i_navigate_to_any_page_in_SAM_AH() throws Throwable {
    homepage.navigateTo();
}

.... }

Could anyone please help in converting the same successfully?

UtsaChakraborty commented 6 years ago

kind of solved....