In selenium framework 2.25, I see that we have the UnexpectedAlertBehaviour enum type, but I don\'t know how to use it.
To manage any of the errors you can got, you only have to put into a try/block using the Exception NAMEERROR like this:
from selenium.common.exceptions import UnexpectedAlertBehaviour
from selenium.common.exceptions import UnexpectedAlertPresentException
try:
var = driver.some_function()
return True
except UnexpectedAlertBehaviour:
print "We have raised the UnexpectedAlertBehaviour"
return False
except UnexpectedAlertPresentException:
print "UnexpectedAlertPresentException"
return False
I know this code is not in Java, but the basis is the same. Try/Catch with name of exception. You can see an example of this on my post of the alerts() handling here