In selenium framework 2.25, I see that we have the UnexpectedAlertBehaviour enum type, but I don\'t know how to use it.
It is a CapabilityType, so you have to express it in the DesiredCapabilities that you pass when creating the driver. In Python I added this behavior to my FireFox drivers using this code:
selenium.webdriver.DesiredCapabilities.FIREFOX["unexpectedAlertBehaviour"] = "accept"
I haven't tested this Java but in theory it should work:
DesiredCapabilities cap = new DesiredCapabailities();
cap.setPreference(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,
org.openqa.selenium.UnexpectedAlertBehaviour.ACCEPT);
WebDriver driver = new FirefoxDriver(cap);