Assuming you're talking about Alerts your AUT invokes then simply write some functions to handle your Alerts, no differently than you would a login dialog, or any other screen in your app.
Here's some quick Python code:
def is_alert_present(self):
try:
el = self.error_or_alert_dialog
if el.exists:
# print "Found error or alert:", el.name_attribute
return True
except:
# print "Did NOT find any error or alert"
return False
# Will attempt to click OK/Yes if there's multiple button choices
def accept(self):
try:
alert = self.driver.switch_to.alert
text = self.all_text
alert.accept()
# print "Accepted alert, text =", text
return True
except:
# print "Warning: Could not accept alert, possibly alert not present"
return False
# Will attempt to click No/Cancel if there's multiple button choices
def dismiss(self):
try:
alert = self.driver.switch_to.alert
text = self.all_text
alert.dismiss()
# print "Dismissed alert, text =", text
return True
except:
# print "Warning: Could not dismiss alert, possibly alert not present"
return False