title: java.lang.NullPointerException---"com.google.common.base.Preconditions.checkNotNull(Preconditions.java:770)"
body: <p>I am new to Selenium and I'm trying to create a small framework in which I login an application and then trying to verify some text inside the account.</p>
  
  <p>But as soon as my script logged into account, the browser gets closed and I am unable to verify text string.</p>
  
  <p>Some people are saying it is because driver is being null and that I need to import base class in LoginPage.<br>
  I tried this as well and got the same issue.</p>
  
  <p><strong>BASE CLASS</strong></p>
  
  <pre><code>package testcases;
  
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.support.PageFactory;
  
  
  import factory.BrowserFactory;
  import factory.DataproviderFactory;
  import pages.LoginPage;
  
  public class baseClass {
  
   WebDriver driver;
  
  
      public void setUP()
      {
          driver=BrowserFactory.getBrowser("chrome");
          driver.get(DataproviderFactory.getConfig().getApplicationurl());
      }
  
      public void loginIntoApplication()
      {
  
          LoginPage login=PageFactory.initElements(driver, LoginPage.class);
          login.Login(DataproviderFactory.getExcel().getData(0, 0, 0), DataproviderFactory.getExcel().getData(0, 0, 1));
  
      }
  
  
      public void TearDown()
      {
          driver.quit();
      }
  
  
  }
  </code></pre>
  
  <p><strong>LOGIN PAGE</strong></p>
  
  <pre><code>package pages;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.support.FindBy;
  import org.openqa.selenium.support.ui.ExpectedConditions;
  import org.openqa.selenium.support.ui.WebDriverWait;
  
  import testcases.baseClass;
  
  
  public class LoginPage extends baseClass {
  
      WebDriver driver;
  
      public LoginPage(WebDriver ldriver) 
      {
          this.driver=ldriver;
      }
  
  
      @FindBy(xpath="//input[@id='log']") WebElement username;
      @FindBy(xpath="//input[@id='pwd']") WebElement password;
      @FindBy(xpath="//input[@id='login']") WebElement LoginButton;
  
      @FindBy(xpath="//li[@id='wp-admin-bar-my-account']/a") WebElement loginVerification;
      public  String loginText;
      public  String Exp="Howdy, AISHWARY";
  
  
  
      public void Login(String uname,String pwd)
      {
          username.sendKeys(uname);
          password.sendKeys(pwd);
          LoginButton.click();
      }
  
      public String LoginVerification()
      {
          WebDriverWait wait=new WebDriverWait(driver, 20);
          wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[@id='wp-admin-bar-my-account']/a")));
          loginText=loginVerification.getText();
          return loginText;
      }
  }
  </code></pre>
  
  <p><strong>testCaseLoginPage</strong></p>
  
  <pre><code>package testcases;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.support.PageFactory;
  import org.openqa.selenium.support.ui.ExpectedConditions;
  import org.openqa.selenium.support.ui.WebDriverWait;
  import org.testng.Assert;
  import org.testng.annotations.AfterTest;
  import org.testng.annotations.BeforeTest;
  import org.testng.annotations.Test;
  
  import pages.LoginPage;
  
  
  public class testCaseLoginPage extends baseClass{
  
      WebDriver driver;
  
      baseClass base=new baseClass();
  
      @BeforeTest
      public void initial()
      {
          base.setUP();
      }
  
      @Test(priority=1)
      public void login()
      {
  
          base.loginIntoApplication();
          LoginPage login=PageFactory.initElements(driver, LoginPage.class);
  
          login.LoginVerification();
          System.out.println(login.loginText);
          Assert.assertEquals(login.loginText, login.Exp,"Unable to verify login verification");
  
      }
  
      @AfterTest
      public void close()
      {
          base.TearDown();
      }
  }
  </code></pre>
  
  <p><strong>Error Log</strong></p>
  
  <pre><code>[TestNG] Running:
    C:\Users\Freak\AppData\Local\Temp\testng-eclipse--1783674419\testng-customsuite.xml
  
  Starting ChromeDriver 2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9) on port 10357
  Only local connections are allowed.
  May 28, 2017 7:08:42 AM org.openqa.selenium.remote.ProtocolHandshake createSession
  INFO: Detected dialect: OSS
  FAILED: login
  java.lang.NullPointerException
      at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:770)
      at org.openqa.selenium.support.ui.FluentWait.&lt;init&gt;(FluentWait.java:96)
      at org.openqa.selenium.support.ui.WebDriverWait.&lt;init&gt;(WebDriverWait.java:71)
      at org.openqa.selenium.support.ui.WebDriverWait.&lt;init&gt;(WebDriverWait.java:45)
      at pages.LoginPage.LoginVerification(LoginPage.java:42)
      at testcases.testCaseLoginPage.login(testCaseLoginPage.java:36)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
      at org.testng.TestRunner.privateRun(TestRunner.java:767)
      at org.testng.TestRunner.run(TestRunner.java:617)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
      at org.testng.SuiteRunner.run(SuiteRunner.java:240)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
      at org.testng.TestNG.run(TestNG.java:1031)
  </code></pre>