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;
}
Object startTimeObject = object.get("startTime", object);
Double startTime = startTimeObject instanceof Double ? (Double) startTimeObject : Double.NaN;
Object endTimeObject = object.get("endTime", object);
Double endTime = endTimeObject instanceof Double ? (Double) endTimeObject : Double.NaN;
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());