Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.WebWindow


        // getUrl() is not visible
        String currentUrl = window.getLocation().toString();
        currentUrl = getUrlBeforeHash(currentUrl);
        String newUrl = getUrlBeforeHash((String) args[0].getValue());
        if (!newUrl.equals(currentUrl)) {
          WebWindow webWindow = window.getWebWindow();
          do {
            webWindow.getJobManager().removeAllJobs();
            webWindow = webWindow.getParentWindow();
          } while (webWindow != webWindow.getTopWindow());
        }
      }
      result = jsEngine.callFunction(htmlPage, jsFunction, window,
          jsThis, jsArgs);
    } catch (ScriptException se) {
View Full Code Here


        page.getHtmlElementById("openInWindowButton").click();
        webClient.waitForBackgroundJavaScript(100);

        verifyTotal(webClient, page, 15);

        WebWindow webWindow = webClient.getWebWindowByName("jscoverage_window");
        ScriptResult result = ((HtmlPage)webWindow.getEnclosedPage()).executeJavaScript("jscoverage_report('directory');");

        assertThat(result.getJavaScriptResult().toString(), equalTo("Coverage data stored at " + new File(getReportDir() + "/directory").getPath()));

        String json = ioUtils.toString(jsonFile);
        assertThat(json, containsString("/script.js"));
View Full Code Here

    protected void testWorkInInvertedMode(int branchPercentage1, int branchPercentage2, int functionPercentage1, int functionPercentage2) throws IOException {
        HtmlPage page = webClient.getPage("http://localhost:9001/example/index.html");
        page.getHtmlElementById("launchJSCover").click();
        webClient.waitForBackgroundJavaScript(100);

        WebWindow webWindow = webClient.getWebWindowByName("jsCoverWindow");
        HtmlPage jsCoverPage = (HtmlPage)webWindow.getEnclosedPage();

        verifyTotal(webClient, jsCoverPage, 15, branchPercentage1, functionPercentage1);

        page.getHtmlElementById("radio3").click();
        webClient.waitForBackgroundJavaScript(100);
View Full Code Here

        page.getHtmlElementById("openInWindowButton").click();
        webClient.waitForBackgroundJavaScript(100);

        //verifyTotal(webClient, page, 15);

        WebWindow webWindow = webClient.getWebWindowByName("jscoverage_window");
        ScriptResult result = ((HtmlPage)webWindow.getEnclosedPage()).executeJavaScript("jscoverage_report();");

        assertThat(result.getJavaScriptResult().toString(), equalTo("Coverage data stored at " + new File(reportDir).getPath()));
    }
View Full Code Here

      try {
        // 1.) try to find frame in current window ...
        currentWindow = currentPage.getFrames().get(index);
      } catch (IndexOutOfBoundsException ignored) {
        // 2.) try to find frame in top window ...
        final WebWindow topWindow = currentWindow.getTopWindow();
        final HtmlPage topPage = (HtmlPage) topWindow.getEnclosedPage();
        try {
          currentWindow = topPage.getFrames().get(index);
        } catch (IndexOutOfBoundsException e) {
          throw new NoSuchFrameException("Cannot find frame: " + index);
        }
View Full Code Here

      try {
        // 1.) try to find frame in current window ...
        currentWindow = findFrame(currentWindow, nameOrIdOrIndex);
      } catch (NoSuchFrameException ignored) {
        // 2.) try to find frame in top window ...
        final WebWindow topWindow = currentWindow.getTopWindow();
        currentWindow = findFrame(topWindow, nameOrIdOrIndex);
      }
      return HtmlUnitDriver.this;
    }
View Full Code Here

      if (isNumericFrameIdValid(nameOrIdOrIndex, startPage)) {
        return getWindowByNumericFrameId(nameOrIdOrIndex, startPage);
      }
      // 3.) Fall back to old behaviour: nameOrIdOrIndex might be a concatenation
      //     of several '.' separated names, ids, or indexes ...
      WebWindow window = startWindow;
      // Walk over all parts of the frame identifier, each time looking for a frame
      // with a name or ID matching this part of the identifier (separated by '.').
      final String[] frames = nameOrIdOrIndex.split("\\.");
      for (int i = 0; i < frames.length; ++i) {
        final String currentFrameId = frames[i];
        final HtmlPage page = (HtmlPage) window.getEnclosedPage();
       
        if (isNumericFrameIdValid(currentFrameId, page)) {
          window = getWindowByNumericFrameId(currentFrameId, page);
        } else {
          // Numeric frame ID is not valid - could be either because the identifier
View Full Code Here

      return null;
    }

  public WebDriver window(String windowId) {
      try {
        WebWindow window = webClient.getWebWindowByName(windowId);
        return finishSelecting(window);
      } catch (WebWindowNotFoundException e) {

        List<WebWindow> allWindows = webClient.getWebWindows();
        for (WebWindow current : allWindows) {
          WebWindow top = current.getTopWindow();
          if (String.valueOf(System.identityHashCode(top)).equals(windowId))
            return finishSelecting(top);
        }
        throw new NoSuchWindowException("Cannot find window: " + windowId);
      }
View Full Code Here

            catch (final MalformedURLException e) {
                throw new IllegalStateException(
                        "Not a valid url: " + getHrefAttribute());
            }
            final WebRequestSettings settings = new WebRequestSettings(url);
            final WebWindow webWindow = enclosingPage.getEnclosingWindow();
            webClient.getPage(
                    webWindow,
                    enclosingPage.getResolvedTarget(getTargetAttribute()),
                    settings);
        }
View Full Code Here

     * Test if the provided URL is the one of one of the parents which would cause an infinite loop.
     * @param url the URL to test
     * @return <code>false</code> if no parent has already this URL
     */
    private boolean isAlreadyLoadedByAncestor(final URL url) {
        WebWindow window = getPage().getEnclosingWindow();
        while (window != null) {
            if (url.sameFile(window.getEnclosedPage().getWebResponse().getRequestSettings().getUrl())) {
                return true;
            }
            if (window == window.getParentWindow()) {
                // TODO: should getParentWindow() return null on top windows?
                window = null;
            }
            else {
                window = window.getParentWindow();
            }
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.WebWindow

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.