title: How to solve NullPointerException in webdriver setup with call in <init>?
body: <pre><code>public class MainPage extends BasePage&lt;MainPage&gt; {
  
      public MainPage(WebDriver driver) {
  
          super(driver);
  
      }
  
      WebDriverWait wait = new WebDriverWait(driver, WAIT_TIME);
  
      public LoginPage clickLoginButton() {
  
          wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Login")));
  
          WebElement GoElement = driver.findElement(By.linkText("Login"));
  
          GoElement.click();
  
          return new LoginPage(driver);
  
      }
  }
  
  // This MainPage mistake--&gt;WebDriverWait wait = new
  // WebDriverWait(driver, WAIT_TIME);
  
  public class UserPage extends BasePage&lt;UserPage&gt; {
  
      public UserPage(WebDriver driver) {
  
          super(driver);
      }
  
      WebDriverWait wait = new WebDriverWait(driver, WAIT_TIME);
  
      public UserPage clickUpdatePasswordButton() throws InterruptedException {
          driver.findElement(By.linkText("Update")).click();
  
          Thread.sleep(2000);
  
          return this;
      }
  }
  </code></pre>
  
  <p>// This UserPage</p>
  
  <pre><code>public class UserTest extends BaseTest {
  
      @Test
      public void UserControl() throws InterruptedException {
  
          new MainPage(driver).clickLoginButton().loginSuccessful("agasgasgasga@gmail.com", "1212121211").checkMainPage().clickToAccount();
      }
  }
  </code></pre>
  
  <p>Code Error:</p>
  
  <pre><code>java.lang.NullPointerException
      at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:212)
      at org.openqa.selenium.support.ui.FluentWait.&lt;init&gt;(FluentWait.java:102)
      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 page.MainPage.&lt;init&gt;(MainPage.java:20)
      at test.UserTest.UserControl(UserTest.java:16)
      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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
      at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
      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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
  
  
  Process finished with exit code 255
  
  
  
  This show mistake
  
  MainPage --&gt; WebDriverWait wait = new WebDriverWait(driver,
  WAIT_TIME);
  </code></pre>