Package org.htmlunit
Class CollectingAlertHandler
- java.lang.Object
-
- org.htmlunit.CollectingAlertHandler
-
- All Implemented Interfaces:
java.io.Serializable,AlertHandler
public class CollectingAlertHandler extends java.lang.Object implements AlertHandler, java.io.Serializable
A simple alert handler that keeps track of alerts in a list.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CollectingAlertHandler()Creates a new instance, initializing it with an empty list.CollectingAlertHandler(java.util.List<java.lang.String> list)Creates an instance with the specified list.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all alerts.java.util.List<java.lang.String>getCollectedAlerts()Returns a list containing the message portion of any collected alerts.voidhandleAlert(Page page, java.lang.String message)Handles the alert.
-
-
-
Constructor Detail
-
CollectingAlertHandler
public CollectingAlertHandler()
Creates a new instance, initializing it with an empty list.
-
CollectingAlertHandler
public CollectingAlertHandler(java.util.List<java.lang.String> list)
Creates an instance with the specified list.- Parameters:
list- the list to store alerts in
-
-
Method Detail
-
handleAlert
public void handleAlert(Page page, java.lang.String message)
Handles the alert. This implementation will store the message in a list for retrieval later.- Specified by:
handleAlertin interfaceAlertHandler- Parameters:
page- the page that triggered the alertmessage- the message in the alert
-
getCollectedAlerts
public java.util.List<java.lang.String> getCollectedAlerts()
Returns a list containing the message portion of any collected alerts.- Returns:
- a list of alert messages
-
clear
public void clear()
Removes all alerts.
-
-