I am getting the following error message in my IntelliJ

enter image description here

The "TestBase.java:33" and "LoginPageTest.java25" essentially both point to the

if(browserName.equals("chrome")) line of code in the base class below.

This is what my base, POM, and test class looks like

Base class:

import com.parabank.qa.util.TestUtil;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

public class TestBase {

   public static WebDriver driver;
   public static Properties prop;

   public TestBase() {
       try {
           prop = new Properties();
           FileInputStream ip = new FileInputStream("/Users/rasha011/Dev/Parabankparasoft/src/main/java/com/parabank/qa/config/config.properties");
       } catch (FileNotFoundException e) {
       } catch (IOException e) {

   public static void initialization(){
       String browserName = prop.getProperty("browser");

           System.setProperty("webdriver.chrome.driver", "/Users/rasha011/Downloads/chromedriver");
           driver = new ChromeDriver();
       } else if(browserName.equals("FireFox")){
           System.setProperty("webdriver.chrome.driver", "/Users/rasha011/Dev/Parabankparasoft/src/main/resources/geckodriver");
           driver = new FirefoxDriver();

       driver.manage().timeouts().pageLoadTimeout(TestUtil.PAGE_LOAD_TIMEOUT, TimeUnit.SECONDS);
       driver.manage().timeouts().implicitlyWait(TestUtil.IMPLICIT_WAIT, TimeUnit.SECONDS);


POM class:

import com.parabank.qa.base.TestBase;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

public class LoginPage extends TestBase {

    //Page Factory
    private WebElement username;

    private WebElement password;

    @FindBy(xpath = "//input[@type='submit']")
    private WebElement loginBtn;

    @FindBy(xpath = "//button[contains(text(),'Sign Up')]")
    private WebElement signUpBtn;

    @FindBy(xpath ="//img[contains(@class,'img-responsive')]")
    private WebElement crmLogo;

    public LoginPage(){
        PageFactory.initElements(driver, this);

    public String validateLoginPageTitle(){
        return driver.getTitle();

    public boolean validateCRMImage(){
        return crmLogo.isDisplayed();

    public HomePage login(String un, String pwd){
        return new HomePage();

Test class:

import com.parabank.qa.base.TestBase;
import com.parabank.qa.pages.HomePage;
import com.parabank.qa.pages.LoginPage;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class LoginPageTest extends TestBase {

    LoginPage loginPage;
    HomePage homepage;

    //I call the base class using the "super" keyword. This way I call the test base constructor which
    //enable me to access the username and password from the properties file
    public LoginPageTest() {

    //This before method will initialize the chrome driver, set waits, and get the web URL
    public void setUp(){
        loginPage = new LoginPage();

    public void loginPageTitleTest(){
        String title = loginPage.validateLoginPageTitle();
        Assert.assertEquals(title, "CRMPRO  - CRM software for customer relationship management, sales, and support.");

    @Test(priority = 2)
    public void crmLogoImageTest(){

    @Test(priority = 3)
    public void loginTest(){
        homepage = loginPage.login(prop.getProperty("username"), prop.getProperty("password"));

    public void tearDown(){

I've doubled checked that the chromedriver exists in the location I specified but I still can't seem to run the test successfully.

  • This is the exact question and issue as this tagged one. – PDHide May 2 '20 at 8:53
  • Even the code is identical – PDHide May 2 '20 at 8:53

You haven't loaded your file to properties object hence you get null when try to obtain a property value. Your code should look like

   public TestBase() {
       try {
           prop = new Properties();
           FileInputStream ip = new FileInputStream("/Users/rasha011/Dev/Parabankparasoft/src/main/java/com/parabank/qa/config/config.properties");
       } catch (FileNotFoundException e) {
       } catch (IOException e) {

By the way it is a good practice to call equals of a constant, not of a variable. This will let you avoid npe. For example:

Not this: if(browserName.equals("chrome"))

But this: if("chrome".equals(browserName))

  • the issue is wit h if(browserName.equals("chrome")) changing it to browserName.contains("chrome") fixes the issue – PDHide May 2 '20 at 8:54
  • How changing from equals to contains can resolve NullPointerException? – Alexey R. May 2 '20 at 9:06
  • 1
    Despite the questions look similar indeed, the one you're referring still has the line prop.load(ip) (unlike this one) so I believe for this particular piece of code (and the line where exception occurs according to OP) the problem is in that properties have not been loaded from a file hence taking prop.getProperty("browser"); return null and obviuosly calling either equals or contains would result in NPE. – Alexey R. May 2 '20 at 9:12
  • 1
    true , i missed that – PDHide May 2 '20 at 9:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.