Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.TopLevelWindow


  @SecondsLong(4)
  @TestType(Type.ACCEPTANCE)
  public void testPushing() throws Exception {
    WebClient c = new WebClient();
    WebWindow w = new TopLevelWindow("1", c);
    c.setCurrentWindow(w);
    HtmlPage p = c.getPage(TEST_URL);
    Thread.sleep(4000);
    int current = Integer.parseInt(p.getElementById("content").getFirstChild().getFirstChild().getTextContent().trim());
    if (current < 3 || current > 5) {
View Full Code Here


  @SecondsLong(12)
  @TestType(Type.ACCEPTANCE)
  public void testConnectionSharing() throws Exception {
    WebClient c = new WebClient();
    WebWindow w1 = new TopLevelWindow("1", c);
    WebWindow w2 = new TopLevelWindow("2", c);
    c.setCurrentWindow(w1);
    String requestId1 = ((HtmlPage) c.getPage(TEST_URL)).getElementById("requestId").getAttribute("value");
    Thread.sleep(1000);
    c.setCurrentWindow(w2);
    String requestId2 = ((HtmlPage) c.getPage(TEST_URL)).getElementById("requestId").getAttribute("value");
    Thread.sleep(500);
    enableDebug(w1);
    enableDebug(w2);
    Thread.sleep(10000);
    System.out.println(getLogForWindows(w1,w2));
    int current = Integer.parseInt(((HtmlPage) w1.getEnclosedPage()).getElementById("content").getFirstChild().getFirstChild().getTextContent().trim());
    if (current < 9 || current > 12) {
      throw new Exception("The value is not in the expected interval:[9,12] for Window 1. The current value:" + current);
    }
    current = Integer.parseInt(((HtmlPage) w2.getEnclosedPage()).getElementById("content").getFirstChild().getFirstChild().getTextContent().trim());
    if (current < 9 || current > 12) {
      throw new Exception("The value is not in the expected interval:[9,12] for Window 2. The current value:" + current);
    }
    if (getLogForWindows(w2).contains("pushnotifications") || getLogForWindows(w1).contains("pushnotifications") == false) {
      throw new Exception("Window 2 is making permanent requests or Window 1 don't");
View Full Code Here

  @Only
  @SecondsLong(25)
  @TestType(Type.ACCEPTANCE)
  public void testFailover() throws Exception {
    WebClient c = new WebClient();
    WebWindow w1 = new TopLevelWindow("1", c);
    WebWindow w2 = new TopLevelWindow("2", c);
    c.setCurrentWindow(w1);
    c.getPage(TEST_URL);
    Thread.sleep(500);
    enableDebug(w1);
    Thread.sleep(500);
    c.setCurrentWindow(w2);
    c.getPage(TEST_URL);
    Thread.sleep(500);
    enableDebug(w2);
    Thread.sleep(4000);
    c.deregisterWebWindow(w1);
    Thread.sleep(20000);
    System.out.println(getLogForWindows(w1,w2));
    int current = Integer.parseInt(((HtmlPage) w2.getEnclosedPage()).getElementById("content").getFirstChild().getFirstChild().getTextContent().trim());
    if (current < 23 || current > 25) {
      throw new Exception("The value is not in the expected interval:[23,25] for Window 2. The current value:" + current);
    }
    c.getPage(TEST_URL_PREFIX + "/leaving/?requestId=" + ((HtmlPage) w2.getEnclosedPage()).getElementById("requestId").getAttribute("value"));
  }
View Full Code Here

         topWindows.add((TopLevelWindow)window);
       }
     }
     for (final Iterator<TopLevelWindow> iter=topWindows.iterator(); iter.hasNext();)
     {
       final TopLevelWindow window = iter.next();
       window.close();
     }

   }
View Full Code Here

        topWindows.add(window);
      }
    }
    for (final Iterator iter=topWindows.iterator(); iter.hasNext();)
    {
      final TopLevelWindow window = (TopLevelWindow) iter.next();
      window.close();
    }
   
    fWebClient = null;
    fPreviousResponse = null;
    fCurrentResponse = null;
View Full Code Here

public class CloseWindow extends Step {

    public void doExecute() throws Exception {
        final Context context = getContext();
       
        final TopLevelWindow window = (TopLevelWindow) context.getCurrentResponse().getEnclosingWindow().getTopWindow();
        window.close();
    }
View Full Code Here

                return;
            }

            // save the URL that should be used to resolve relative URLs in this page
            if (enclosingWindow instanceof TopLevelWindow) {
                final TopLevelWindow topWindow = (TopLevelWindow) enclosingWindow;
                final WebWindow openerWindow = topWindow.getOpener();
                if (openerWindow != null && openerWindow.getEnclosedPage() != null) {
                    baseUrl_ = openerWindow.getEnclosedPage().getWebResponse()
                    .getRequestSettings().getUrl();
                }
            }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.TopLevelWindow

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.