title: PhantomJSDriver Accept Alert
body: <p>How can I accept an alert with PhantomJSDriver in Java? I am trying to do this with YouTube. I can't get it to work.</p>
  
  <p>I've tried using this code to accept on any driver but it doesn't work with PhantomJS.</p>
  
  <pre><code>static void confirmDialog(WebDriver driver) {
      if (driver instanceof PhantomJSDriver) {
          PhantomJSDriver phantom = (PhantomJSDriver) driver;
          phantom.executeScript("window.confirm = function(){return true;}");
          phantom.executeScript("return window.confirm");
      } else driver.switchTo().alert().accept();
  }
  </code></pre>