Package org.htmlunit

Class WebClient.CurrentWindowTracker

java.lang.Object
org.htmlunit.WebClient.CurrentWindowTracker
All Implemented Interfaces:
Serializable, WebWindowListener
Enclosing class:
WebClient

private static final class WebClient.CurrentWindowTracker extends Object implements WebWindowListener, Serializable
Keeps track of the current window. Inspired by WebTest's logic to track the current response.
  • Field Details

    • webClient_

      private final WebClient webClient_
    • ensureOneTopLevelWindow_

      private final boolean ensureOneTopLevelWindow_
  • Constructor Details

    • CurrentWindowTracker

      CurrentWindowTracker(WebClient webClient, boolean ensureOneTopLevelWindow)
  • Method Details

    • webWindowClosed

      public void webWindowClosed(WebWindowEvent event)
      A web window has been closed. Closing the last window of the WebClient will automatically open a new one. You will receive an additional open event in this case.
      Specified by:
      webWindowClosed in interface WebWindowListener
      Parameters:
      event - the event
    • afterWebWindowClosedListenersProcessed

      public void afterWebWindowClosedListenersProcessed(WebWindowEvent event)
      Postprocessing to make sure we have always one top level window open.
    • webWindowContentChanged

      public void webWindowContentChanged(WebWindowEvent event)
      The contents of a web window has been changed.
      Specified by:
      webWindowContentChanged in interface WebWindowListener
      Parameters:
      event - the event
    • webWindowOpened

      public void webWindowOpened(WebWindowEvent event)
      A web window has been opened.

      Caution: the WebClient.getCurrentWindow() might be not updated so far. This usually takes place AFTER the event was processed

      Specified by:
      webWindowOpened in interface WebWindowListener
      Parameters:
      event - the event (the oldPage and newPage properties will be null because the event is generated after the window is opened but before the content is loaded)