title: How to pass same browser instance across different class in selenium framework
body: <p>I have a basic doubt on selenium framework on which I am working currently.
  I have a driver class where the chrome-driver is initialized.</p>
  
  <pre><code> public class page1 {
  
              private static  WebDriver driver;
              protected static String WINDOWS_DRIVER = "/chromedriver/windows/chromedriver.exe";
              public static WebDriver initi(){
              if(driver == null){
                  System.setProperty("webdriver.chrome.driver",page1.class.getResource(WINDOWS_DRIVER).getFile());
                  DesiredCapabilities capabilities = DesiredCapabilities.chrome();
                  ChromeOptions options = new ChromeOptions();
                  options.addArguments("test-type");
                  options.addArguments("--start-maximized");
                  options.addArguments("--ignore-certificate-errors");
                  capabilities.setCapability(ChromeOptions.CAPABILITY, options);
                  driver=new ChromeDriver(capabilities);
  
          }
  
          return driver;
      }
  }
  </code></pre>
  
  <p>I have 2 classes which extends the driver class.</p>
  
  <pre><code>    public class page2 extends page1 {
      public WebDriver driver;
  
      public void testmethod1(){
          driver=super.initi();
          driver.navigate().to("https://www.google.co.in/");
      }
  }
  
      public class page3 extends page1 {
  
      public WebDriver driver;
      public void testmethod2(){
          driver=super.initi();
          driver.navigate().to("https://in.yahoo.com/?p=us");
      }
  }
  </code></pre>
  
  <p>Finally, I have a testsuite class where I want to create a single browser instance and call methods of all 3 classes.</p>
  
  <pre><code>    public class finalclass extends page1{
  
      public page2 _page2;
      public page3 _page3;
  
      public WebDriver driver;
  
      @Test
      public void finaltest(){
  
          driver=super.initi();
          driver.get("http://www.rediff.com/");
          _page2.testmethod1();
          _page3.testmethod2();
  
      }
  }
  </code></pre>
  
  <p>It is throwing null pointer exception error on the function call. Can you please help.</p>