How to get Alert object with PhantomJSDriver in java?
<p>I'm trying PhantomJSDriver for testing application and I got errors to get Selenium equivalent of Alert object. I've tried this :</p>

<pre><code>if (driver instanceof PhantomJSDriver) {
    PhantomJSDriver phantom = (PhantomJSDriver) driver;
    Alert alert = (Alert) phantom.executeScript("return window.alert;");
} 
else {
    Alert alert = driver.switchTo().alert();
}
</code></pre>

<p>but it doesn't work.
How can I get Alert object ?</p>