title: Null pointer exception for alerts: JAVA
body: <p>Here is my code:</p>
  <pre><code>public class BasePage extends PageObject {
  
    @Managed
     WebDriver driver;
  
      
      public Alert waitingForAlert() throws InterruptedException {
          Alert al = driver.switchTo().alert();
          return al;
      }
  </code></pre>
  <p>I'm getting the error</p>
  <p>java.lang.NullPointerException: Cannot invoke &quot;org.openqa.selenium.WebDriver.switchTo()&quot; because &quot;this.driver&quot; is null</p>