title: Selenium POM java.lang.NullPointerException
body: <p>I am getting "java.lang.NullPointerException" when I am trying to execute my test case based on POM.
  The class BrowserFactory lets me choose a browser, the class Flipkart_Login based on POM stores all the element of that particular page and has a method for Valid_Login()
  and finally Test_Flipkart_Login class - calls the Valid_Login() method for executon but when I try to execute this class, I get java.lang.NullPointerException.</p>
  
  <p>Kindly advise!</p>
  
  <p>FAILED: Flipkart_Login_Test
  java.lang.NullPointerException
      at DataProviders.ConfigDataProvider.getURL(ConfigDataProvider.java:31)
      at TestCases.Test_Flipkart_Login.Flipkart_Login_Test(Test_Flipkart_Login.java:19)</p>
  
  <p>public class ConfigDataProvider 
  {
      static Properties pro;</p>
  
  <pre><code>public ConfigDataProvider()
  {
  
      File src = new File("C:\\Data\\Bimlesh\\Flipkart_HybridFramework\\Flipkart.Hybrid.FrameworkComplete\\Configuration\\Config.Properties");
  
      try 
      {
          FileInputStream fis = new FileInputStream(src);
          pro = new Properties();
          pro.load(fis);
  
      } catch (Exception e) 
      {
          System.out.println("The Config exception is :"+e.getMessage());
      }
  
  }
  
  public static String getURL()
  {
      String URL = pro.getProperty("URL");
      return URL;
  }
  
  public static String ChromePath()
  {
      String Chrome = pro.getProperty("Chromepath");
      return Chrome;
  }
  
  public static String IEPath()
  {
      String IE = pro.getProperty("IEpath");
      return IE;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>public class BrowserFactory 
  {
      static WebDriver driver;</p>
  
  <pre><code>public static WebDriver getBrowser(String BrowserName)
  {
      if(BrowserName.equalsIgnoreCase("Firefox"))
      {
          driver = new FirefoxDriver();
      }
      else if(BrowserName.equalsIgnoreCase("Chrome"))
      {
          System.setProperty("webdriver.chrome.driver", ConfigDataProvider.ChromePath());
          driver = new ChromeDriver();
      }
      else if(BrowserName.equalsIgnoreCase("IE"))
      {
          System.setProperty("webdriver.ie.driver", ConfigDataProvider.IEPath());
          driver = new InternetExplorerDriver();
      }
  
      driver.manage().window().maximize();
      driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
      return driver;
  }
  
  public void ShutDown(WebDriver driver)
  {
      driver.quit();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>public class Flipkart_Login 
  {
      WebDriver driver;</p>
  
  <pre><code>public Flipkart_Login(WebDriver driver)
  {
      this.driver=driver;
  }
  
  @FindBy(xpath="//a[text()='Log In']") WebElement Login_Click;
  @FindBy(xpath="//input[@class='_2zrpKA' and @type='text']") WebElement Enter_Email;
  @FindBy(xpath="//input[@class='_2zrpKA _3v41xv' and @type='password']") WebElement Enter_Pass;
  @FindBy(xpath="//button[@type='submit' and @class='_3zLR9i _1LctnI _36SmAs']") WebElement Login_Button;
  
  public void Valid_Login()
  {
      Login_Click.click();
      Enter_Email.sendKeys("xxx@gmail.com");
      Enter_Pass.sendKeys("xxx");
      Login_Button.click();
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>public class Test_Flipkart_Login 
  {
      WebDriver driver;</p>
  
  <pre><code>@Test
  public void Flipkart_Login_Test()
  {
      driver = BrowserFactory.getBrowser("Firefox");
      driver.get(ConfigDataProvider.getURL());
      Flipkart_Login page1 = PageFactory.initElements(driver, Flipkart_Login.class);
      page1.Valid_Login();
  
  }
  </code></pre>
  
  <p>}</p>