Package org.htmlunit

Class WebClient.CurrentWindowTracker

  • All Implemented Interfaces:
    java.io.Serializable, WebWindowListener
    Enclosing class:
    WebClient

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

      • webClient_

        private final WebClient webClient_
      • ensureOneTopLevelWindow_

        private final boolean ensureOneTopLevelWindow_
    • Constructor Detail

      • CurrentWindowTracker

        CurrentWindowTracker​(WebClient webClient,
                             boolean ensureOneTopLevelWindow)
    • Method Detail

      • 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.
      • 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)