title: How to use the initialized Webdriver instance from Base class to child class java
body: <pre><code>public class Base 
  {
      public WebDriver driver;
  
      @BeforeMethod 
      public void setUp()
      {
          driver = new FirefoxDriver();
      }
  
  }
  
  public class useFunction extends Base
  {
  
      public useFunction(WebDriver driver)
      {
          this.driver = driver;
      }
  
      public void func1()
      {
          driver.findElement().click();  //driver is null
          --------
          ---------
      }
  }
  
  Public class Test extends Base
  {
      useFunction funObj = new useFunction(driver);
      @Test
      public void testMethod1()
     {
         funObj.func1();
         ----
         ------ 
  
    }
  }
  </code></pre>
  
  <p><strong>How can i use the initialized value of WebDriver instance in <code>UseFunction class</code> without declaring the Webdriver instance as static.</strong> When i pass the driver in constructor of <code>UseFunction class</code> while creating its object inside <code>Test class</code>, getting Null Pointer Exception</p>