Iterator<String> keys = testsMap.keySet().iterator();
long now = System.currentTimeMillis();
long inactivityLimit = Configuration.getMaxPageLoadTime();
while (keys.hasNext()) {
String sessionId = (String) keys.next();
Session session = Session.getExistingInstance(sessionId);
if (session == null) continue;
long lastActiveTime = session.lastActiveTime();
Status status = session.getStatus();
if (status != Status.SUCCESS && status != Status.FAILURE
&& status != Status.INITIAL
&& now - lastActiveTime > inactivityLimit) {
String message = "*** Forcefully terminating script. \nNo response from browser within expected time ("
+ inactivityLimit / 1000 + " seconds).";
System.out.println(message);
ScriptRunner scriptRunner = session.getScriptRunner();
scriptRunner.setStatus(Status.FAILURE);
Report report = scriptRunner.getReport();
if (report != null) {
report.addResult(message, "ERROR", "", "");
}