Package org.openqa.selenium.htmlunit
Class HtmlUnitAlert
java.lang.Object
org.openqa.selenium.htmlunit.HtmlUnitAlert
- All Implemented Interfaces:
org.openqa.selenium.Alert
Provides an implementation of
Alert for HtmlUnitDriver.
Handles JavaScript alert, confirm, prompt, and beforeunload dialogs.- Author:
- Ahmed Ashour, A aftakhov, Ronald Brill
-
Method Summary
Modifier and TypeMethodDescriptionvoidaccept()voiddismiss()voidEnsures that any active alert is handled according to the configuredUnexpectedAlertBehaviour.getText()voidhandleBrowserCapabilities(org.openqa.selenium.Capabilities capabilities) Configures the behavior for unexpected alerts based on the given capabilities.voidvoidsetAutoAccept(boolean autoAccept) Sets whether alerts should be automatically accepted when the driver is quitting.
-
Method Details
-
setAutoAccept
public void setAutoAccept(boolean autoAccept) Sets whether alerts should be automatically accepted when the driver is quitting.- Parameters:
autoAccept-trueto automatically accept alerts;falseotherwise
-
handleBrowserCapabilities
public void handleBrowserCapabilities(org.openqa.selenium.Capabilities capabilities) Configures the behavior for unexpected alerts based on the given capabilities.- Parameters:
capabilities- the browser capabilities to inspect for unhandled prompt behavior
-
dismiss
public void dismiss()- Specified by:
dismissin interfaceorg.openqa.selenium.Alert
-
accept
public void accept()- Specified by:
acceptin interfaceorg.openqa.selenium.Alert
-
getText
- Specified by:
getTextin interfaceorg.openqa.selenium.Alert
-
sendKeys
- Specified by:
sendKeysin interfaceorg.openqa.selenium.Alert
-
ensureUnlocked
public void ensureUnlocked()Ensures that any active alert is handled according to the configuredUnexpectedAlertBehaviour. If an alert is present and the behavior is notIGNORE, it will be accepted or dismissed. If the behavior indicates notification, anUnhandledAlertExceptionis thrown.- Throws:
org.openqa.selenium.UnhandledAlertException- if an unexpected alert is found and notification is required
-