Package com.gargoylesoftware.htmlunit

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

        System.out.println();
        System.out.println("Logged Javascript statements:");
        System.out.println("*****************************");
        System.out.println(loggedJavaScript.toString());
View Full Code Here


    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

TOP

Related Classes of com.gargoylesoftware.htmlunit.ScriptResult

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.