Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

NullPointer Exception when use the Driver instance #242

Open
Chankami opened this issue Jul 7, 2020 · 2 comments
Open

NullPointer Exception when use the Driver instance #242

Chankami opened this issue Jul 7, 2020 · 2 comments
Labels

Comments

@Chankami
Copy link

Chankami commented Jul 7, 2020

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
Copy link
Member

wakaleo commented Jul 7, 2020

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
Copy link
Author

Chankami commented Jul 7, 2020

Thanks alot

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants