0

How the alerts in HtmlUnit will be handled? For Supposeenter image description here

It is not required to click "OK" in htmlUnit. But in selenium, it will throw UnhandledAlertException. How it is different in HtmlUnit from Selenium.

Sumanth
  • 1
  • 1

1 Answers1

1

HtmlUnit does not stop the processing when an alert is reached - instead there is an alert handler (registered for the client) that decides how to proceed.

The default alert handler simply accepts the alert (clicks the ok button).

You can register your own AlertHandler (htmlunit/src/main/java/com/gargoylesoftware/htmlunit/AlertHandler.java) and process every alert individually (if required).

RBRi
  • 2,704
  • 2
  • 11
  • 14
  • Does it mean even without handling the alert from our end, HtmlUnit have its default AlertHandler which accepts all alerts whenever an Alert encountered? – Sumanth Nov 12 '19 at 16:17