I am getting java.lang.NullPointerException while executing my test case , I am using Page Object Modle with PageFactory ,following are the code snippets
TestBase Class:
ackage com.base;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import pagefactory.Scorex_LoginPage;
import pagefactory.Scorex_HomePage;
public class TestBase {
protected WebDriver driver;
protected String baseUrl = "http://scorex.domain.com/";
protected Scorex_LoginPage objLogin;
protected Scorex_HomePage objHome;
@BeforeMethod
public void initializeBrowser() {
driver = new FirefoxDriver();
driver.get(baseUrl);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.manage().window().maximize();
}
@AfterMethod
public void closeBrowser(){
driver.quit();
}
}
Test Case Class:
package tests;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.base.TestBase;
public class Scorex_LoginTestCases extends TestBase{
@Test(priority=1) //TC01
public void Scorex_valid_email_password()
{
objLogin.loginScoreAs("[email protected]", "superadmin");
String DashboardUserName = objHome.getHomePageUserName();
Assert.assertTrue(DashboardUserName.contains("Super Admin"));
}
}