title: Selenium Web Driver : Handle Confirm Box using Java
body: <p>Hi I am using the following code for handling the alert box after clicking an action but it isn't working
  Can somebody please help.</p>
  
  <p>This is where I call the handler. clickOnAlert() after clickOnAddQuote() is called alert box appears.</p>
  
  <pre><code>System.out.println("before add to quote");
  this.clickOnAddQuote();
  System.out.println("before alert");
  this.clickOnAlert();
  System.out.println("after alert");
  </code></pre>
  
  <p>function clickOnAlert()</p>
  
  <pre><code>public void clickOnAlert() {
          System.out.println("In click");
          Alert alert = webdriverSession().switchTo().alert();
          System.out.println("after constructor");
          alert.accept();
      }
  </code></pre>
  
  <p>Please help.
  Thanks</p>