Package org.htmlunit
Class CollectingAlertHandler
java.lang.Object
org.htmlunit.CollectingAlertHandler
- All Implemented Interfaces:
Serializable
,AlertHandler
A simple alert handler that keeps track of alerts in a list.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance, initializing it with an empty list.CollectingAlertHandler
(List<String> list) Creates an instance with the specified list. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all alerts.Returns a list containing the message portion of any collected alerts.void
handleAlert
(Page page, String message) Handles the alert.
-
Constructor Details
-
CollectingAlertHandler
public CollectingAlertHandler()Creates a new instance, initializing it with an empty list. -
CollectingAlertHandler
Creates an instance with the specified list.- Parameters:
list
- the list to store alerts in
-
-
Method Details
-
handleAlert
Handles the alert. This implementation will store the message in a list for retrieval later.- Specified by:
handleAlert
in interfaceAlertHandler
- Parameters:
page
- the page that triggered the alertmessage
- the message in the alert
-
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.
-