serenity-bdd / serenity-cucumber

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

DefaultUrl for PageObjects is not working in case CucumberWithSerenity is in use #15

Closed girt-s closed 8 years ago

girt-s commented 9 years ago

If we will have a following PageObject class:

@DefaultUrl("http://something")
public class LoginPage extends PageObject{
}

and will run test with SerenityRunner, following tests will be executed successfully, page will be opened:

@RunWith(SerenityRunner.class)
public class Login {

  @Managed
  WebDriver driver;

  @Steps
  LoginPage loginPage;

  @Test
  public void login() {
    loginPage.open();
  }

If we will run the same code with CucumberWithSerenity

Runer:

@RunWith(CucumberWithSerenity.class)
public class CuceRunner {}

Steps Definition:

public class LoginStepsDefinition {

  @Managed
  WebDriver driver;

  @Steps
  LoginPage loginPage;

  @Given("Login Page is opened")
  public void loginPageIsOpened() {
     loginPage.open();
  }
}

following error will be returned: java.lang.AssertionError: Undefined default URL for page object PageNotFound$$EnhancerByCGLIB$$dc6a9f70

even though same PageObject is successfully working with SerenityRunner runner. serenity-core version 1.0.47. serenity-cucumber 1.0.15

wakaleo commented 9 years ago

See if this is happening in serenity 1.0.58 and serenity-cucumber 1.0.18, and, if so, please post a full stack trace.

YamStranger commented 8 years ago

It seems that this issue already fixed and can not be reproduced

mrunalgosar commented 8 years ago

I will have to re-open this issue again as I see this issue again in 1.1.8 version of serenity-cucumber Stacktrace: java.lang.AssertionError: Undefined default URL for page object SamplePage$$EnhancerByCGLIB$$2d2c6321 at net.serenitybdd.core.pages.PageUrls.verified(PageUrls.java:69) at net.serenitybdd.core.pages.PageUrls.getStartingUrl(PageUrls.java:47) at net.serenitybdd.core.pages.PageObject.open(PageObject.java:737) at net.serenitybdd.core.pages.PageObject.open(PageObject.java:726) at serenity.StepDefs.step1(StepDefs.java:19) at ?.Given some step1(sample.feature:7)

wakaleo commented 8 years ago

Could you include the code for your SamplePage class?

mrunalgosar commented 8 years ago

Attaching a sample project to reproduce. serenity-cucumber-practise.zip

mrunalgosar commented 8 years ago

Any updates on this? Are you able to reproduce this issue via the attached sample code.

cliviu commented 8 years ago

hi @mrunalgosar , I will take a look at you issue. I was able to reproduce it using your test program.

cliviu commented 8 years ago

hi @mrunalgosar , in the class StepDefs, please remove the @Steps annotation from the GitHubHomePage page field. It is wrong at that place. Also, please close the issue if you feel that this answers your question. Thanks !

mrunalgosar commented 8 years ago

hi @cliviu as per my understanding @Steps annotation is used for steps injection in serenity, I wanted to do steps injection in my step definitions which is why it is there. What is the right otherwise in serenity then?

steps commented 8 years ago

I don't know what you guys are doing, but whenever someone writes @steps I get an email because you are mentioning my username ;-)

On 19 Jun 2016, at 16:38, n notifications@github.com wrote:

hi @cliviu as per my understanding @Steps annotation is used for steps injection in serenity, I wanted to do steps injection in my step definitions which is why it is there. What is the right otherwise in serenity then?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

cliviu commented 8 years ago

hi @mrunalgosar . In your example GitHubHomePage extends PageObject. The "@"Steps annotation must be used on net.thucydides.core.steps.ScenarioSteps implementations. The PageObject implementations do not need any annotation, they are automatically detected by Serenity framework.

mrunalgosar commented 8 years ago

So in my stepdefs class i must create an instance field of GitHubHomePage and use it some thing like this? `public class StepDefs {

private GitHubHomePage page=new GitHubHomePage();

@Given("login to github")
public void login() {
    page.open();
    page.login("mrunal", "password");
}

}`

wakaleo commented 8 years ago

No, see http://serenity-bdd.info/docs/serenity/#_serenity_step_libraries_and_page_objects

On 19 June 2016 at 17:05, mrunalgosar notifications@github.com wrote:

So in my stepdefs class i must create an instance field of GitHubHomePage and use it some thing like this? `public class StepDefs {

private GitHubHomePage page=new GitHubHomePage();

@Given("login to github") public void login() { page.open(); page.login("mrunal", "password"); }

}`

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/serenity-bdd/serenity-cucumber/issues/15#issuecomment-227005210, or mute the thread https://github.com/notifications/unsubscribe/AADasjMGp3CPDA5QEm6nkk4wmHiyjgDKks5qNWjlgaJpZM4EY7gG .


John Smart | Wakaleo Consulting | +44 7398 832273 Making smart teams collaborate better http://johnfergusonsmart.com | john.smart@wakaleo.com


We love breaking down silos and helping smart teams collaborate better! Ask about our tailored on-site workshops http://johnfergusonsmart.com/programs/ in Agile Product Planning http://johnfergusonsmart.com/programs-courses/next-generation-agile-delivery-product-planning/, BDD Requirements Discovery http://johnfergusonsmart.com/programs-courses/mastering-agile-requirements-behaviour-driven-development/, BDD, TDD and Clean Coding http://johnfergusonsmart.com/programs-courses/bdd-tdd-clean-coding/, and Advanced BDD Test Automation http://johnfergusonsmart.com/programs-courses/advanced-bdd-test-automation/ .


cliviu commented 8 years ago

@mrunalgosar , The best thing I thing is to take a closer look at the docs , as @wakaleo suggested. You can find also a good example at https://github.com/serenity-bdd/serenity-demos/tree/master/cucumber-webtests.

mrunalgosar commented 8 years ago

Got it..I can confirm now the above behavior..Thanks @wakaleo and @cliviu

cliviu commented 8 years ago

You're welcome. Please close the issue .. Thanks!