Examples of ScriptResult


Examples of com.gargoylesoftware.htmlunit.ScriptResult

        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"));

        page = webClient.getPage("file:///"+ new File(getReportDir()+"/directory/jscoverage.html").getAbsolutePath());
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

        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

Examples of com.gargoylesoftware.htmlunit.ScriptResult

        assertThat(frame.getByXPath("//span[contains(@class,'failed')]").size(), equalTo(0));
        assertThat(frame.getByXPath("//span[contains(@class,'skipped')]").size(), equalTo(0));
        assertThat(passed.get(0).asText(), equalTo("16 specs, 0 failures"));

        //Store Report
        ScriptResult result = frame.executeJavaScript("jscoverage_report();");

        //Verify coverage
        page.getHtmlElementById("summaryTab").click();
        webClient.waitForBackgroundJavaScript(2000);
        assertEquals("100%", page.getElementById("summaryTotal").getTextContent());
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

 
  protected TestsResult getTestsResult() {
    TestsResult result = new TestsResult();

    executeTimer();
    ScriptResult scriptResult = page.executeJavaScript("window.simulationContext.results");
    NativeArray array = (NativeArray) scriptResult.getJavaScriptResult();
   
    for (int i = 0; i < array.getLength(); i++) {
      NativeObject object = (NativeObject) array.get(i, array);

      String data = null;
     
      Object dataObject = object.get("data", object);
      if (!(dataObject instanceof Undefined)) {
        data = (String) dataObject;
      }
     
      Double startTime = (Double) object.get("startTime", object);
      Double endTime = (Double) object.get("endTime", object);
     
      Object aborted = object.get("aborted", object);
      boolean abortedBoolean = aborted instanceof Boolean && (Boolean) aborted;
     
      result.addData(new RequestData(data, startTime, endTime, abortedBoolean));
    }
   
    scriptResult = page.executeJavaScript("Timer.currentTime");
    result.setCurrentTime((Double) scriptResult.getJavaScriptResult());
   
    return result;
  }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

        final JavaScriptEngine engine = htmlElement.getPage().getWebClient().getJavaScriptEngine();
        if (engine.isScriptRunning()) {
            return page;
        }
        final ScriptResult scriptResult = htmlElement.fireEvent(Event.TYPE_CHANGE);

        if (page.getWebClient().getWebWindows().contains(page.getEnclosingWindow())) {
            return page.getEnclosingWindow().getEnclosedPage(); // may be itself or a newly loaded one
        }
        else if (scriptResult != null) {
            // current window doesn't exist anymore
            return scriptResult.getNewPage();
        }

        return page;
    }
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

      }
    }

    if (submit == null) {
      if (parent.isJavascriptEnabled()) {
        ScriptResult eventResult = form.fireEvent("submit");
        if (!ScriptResult.isFalse(eventResult)) {
          parent.executeScript("arguments[0].submit()", form);
        }
        return;
      } else {
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

    for (int i = 0; i < args.length; i++) {
      parameters[i] = parseArgumentIntoJavsacriptParameter(args[i]);
    }

    script = "function() {" + script + "};";
    ScriptResult result = page.executeJavaScript(script);
    Function func = (Function) result.getJavaScriptResult();

    result = page.executeJavaScriptFunctionIfPossible(
        func,
        (ScriptableObject) currentWindow.getScriptObject(),
        parameters,
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

        final HtmlPage htmlPage = (HtmlPage) getPage();
        final WebClient webClient = htmlPage.getWebClient();
        if (webClient.isJavaScriptEnabled()) {
            if (submitElement != null) {
                isPreventDefault_ = false;
                final ScriptResult scriptResult = fireEvent(Event.TYPE_SUBMIT);
                if (isPreventDefault_) {
                    return scriptResult.getNewPage();
                }
            }

            final String action = getActionAttribute();
            if (TextUtil.startsWithIgnoreCase(action, JAVASCRIPT_PREFIX)) {
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

     *
     * @return the page contained by this form's window after the reset
     */
    public Page reset() {
        final SgmlPage htmlPage = getPage();
        final ScriptResult scriptResult = fireEvent(Event.TYPE_RESET);
        if (ScriptResult.isFalse(scriptResult)) {
            return scriptResult.getNewPage();
        }

        for (final HtmlElement next : getHtmlElementDescendants()) {
            if (next instanceof SubmittableElement) {
                ((SubmittableElement) next).reset();
View Full Code Here

Examples of com.gargoylesoftware.htmlunit.ScriptResult

        }

        Page page = getPage();

        if (changed) {
            final ScriptResult scriptResult = fireEvent(Event.TYPE_CHANGE);
            if (scriptResult != null) {
                page = scriptResult.getNewPage();
            }
        }
        return page;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.