serenity-bdd / serenity-cucumber

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

NullPointer Exception when use the Driver instance #242

Open Chankami opened 4 years ago

Chankami commented 4 years ago

I'm using serenity cucumber starter pack. Whenever I use WebDriver instance it throws a null pointer. My requirement is to pass the driver to a third-party lib. When print current URL also it throws the NullPointer.

public class ScreenShots extends PageObject {
    @Managed
    WebDriver driver;
public void capturefullPageScreenshotry() 
   XX.shootPage(driver,XX.WHOLE_PAGE).save();
  System.out.println("currentURL"+driver.getCurrentUrl());
}}

Also, when tried to use driver. get() instead of open() it thorws a null pointer @Step("Navigates to Homepage") public void navigateHomePage() { driver.get("https://ishopchangi.com/"); //open(); commons.waitForPageLoad(); } Can you pls help me to sort this .

wakaleo commented 4 years ago

That's not how Serenity works. You don't use the @Managed annotation with Cucumber, and you don't place a driver field in a Page Object class. Have a look at https://serenity-bdd.github.io/theserenitybook/latest/index.html.

Chankami commented 4 years ago

Thanks alot