The code runs fine but I created a new page object for a new page to test but I am getting this null pointer exception. Here are the two class I believe I am having issues with.
public class LoggedInPageSteps {
WebDriver driver;
private Logger logger = Logger.getLogger(HomePage.class);
LoggedInPage loggedInPage;
@Then ("^I check the my account info tag$")
public void verifyLoggedInPage() {
logger.info("Inside loggedinpagesteps verifyloggedin function.");
logger.info(loggedInPage.getAcctInfoTag());
loggedInPage.checkLoggedIn();
//Commons.check(loggedInPage.getAcctInfoTag().equals("My Account Information"), driver,
"Title doesnt match");
}
and
public class LoggedInPage {
@FindBy(tagName = "h1")
WebElement acctInfoTag;
WebDriver driver;
//LoggedInPage loggedInPage;
private Logger logger = Logger.getLogger(LoginPage.class);
public LoggedInPage(WebDriver driver) {
this.driver = driver;
PageFactory.initElements(driver, this);
}
public String getAcctInfoTag() {
logger.info("insdie LoggedInPage funcrion getAccountInfoTag().");
return Commons.getElementText(driver, acctInfoTag, 5);
}
public void checkLoggedIn() {
logger.info("Inside LoggedInPage inside function CheckLoggedIn.");
logger.info(Commons.getElementText(driver, acctInfoTag, 5));
Commons.check(Commons.getElementText(driver, acctInfoTag, 5).equals("My Account
Information"), driver, "Not on logged in page.");
}
}
Is it a webdriver issue? I am new to automation testing so forgive me if it was a simple mistake.