title: Static webdriver is null in selenium
body: <p>I am starting with selenium and also read about the Page Object Model. I tried to implement sample code and now i have 2 questions:</p>
  
  <ol>
  <li>How do i start another test case after the login is tested?</li>
  <li>I implemented a static WebDriver to access it from everywhere. Why is it null in case 2?</li>
  </ol>
  
  <p>My WebDriver-Class:</p>
  
  <pre><code>public class BrowserFactory {
  
  
  public static WebDriver driver;
  
  @BeforeClass
  public static WebDriver startBrowser(String browserName, String url) throws Exception {
  
      System.setProperty("webdriver.gecko.driver","C:\\selenium-driver\\geckodriver.exe");
      System.setProperty("webdriver.chrome.driver","C:\\selenium-driver\\chromedriver.exe");
  
      if (browserName.equals("")) {
          System.out.println("No Browser Parameter given, use default Browser Firefox");
          browserName = "Firefox";
      }
  
      if (browserName.equalsIgnoreCase("Firefox")) {
          driver = new FirefoxDriver();
      } else if (browserName.equalsIgnoreCase("Chrome")) {
          driver = new ChromeDriver();
      } else if(browserName.equalsIgnoreCase("IE")){
          driver = new InternetExplorerDriver();
      }else {
          System.out.println("Browser not defined!");
          throw new Exception("Browser not defined!");
      }
  
      driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
      driver.manage().window().maximize();
      driver.get(url);
  
      return driver;
  }
  
  @AfterClass
  public void teardown () {
      driver.quit();
  }
  }
  </code></pre>
  
  <p>LoginTest-Class (working):</p>
  
  <pre><code>public class LoginPageTest {
  
  
  @Test
  public void checkValidUser() throws Exception {
  
      BrowserFactory.driver = BrowserFactory.startBrowser("Chrome","http://localhost:8080/cleo");
      LoginPage loginPage=new LoginPage(BrowserFactory.driver);
      KundenverwaltungPage kundenVerwaltungPage = new KundenverwaltungPage(BrowserFactory.driver);
  
      assertTrue(loginPage.isInitialized());
  
      loginPage.loginCleo("makler1", "12345a");
  
      assertTrue(kundenVerwaltungPage.isInitialized());
  
  }
  }
  </code></pre>
  
  <p>Test-Case 2:</p>
  
  <pre><code>public class SecondCasePageTest {
  
  @Test
  public void processSelectedKunden() throws Exception {
  
      System.out.println(BrowserFactory.driver);
  
      SecondCasePage scPage = new SecondCasePage(BrowserFactory.driver);
  
      assertTrue(scPage.isInitialized());
  
      scPage.selectCostumer(0);
  
  
  }
  }
  </code></pre>