I am trying to do something conceptually simple... We have multiple portlets loading on a Dashboard. I need to measure the load time that each takes. I have implemented a simple StopWatch class, and need to run multiple instance of it simultaneously, for each portlet, while the Dashboard is loading. So the parameters supplied will be - 1. The portlet name, 2. The element to be checked, indicating a successful load. Here is the StopWatch class:
public class StopWatch implements Runnable {
private long startTime;
private long stopTime;
private String tElement;
private String tPortletName;
public StopWatch(String portletName,String element) {
tElement = element;
tPortletName = portletName;
}
public void start() {
startTime = System.currentTimeMillis();
}
public void stop() {
stopTime = System.currentTimeMillis();
}
public long getTime() {
return stopTime - startTime;
}
@Override
public void run() {
selenium.selectFrame(tPortletName);
StopWatch sw = new StopWatch();
sw.start();
while (selenium.isElementPresent(tElement)==false)
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
sw.stop();
long time = sw.getTime();
System.out.println(tPortletName+" load time="+time);
}
}
In the calling program,
StopWatch sw1 = new StopWatch(portlet1,element1);
StopWatch sw2 = new StopWatch(portlet2,element2);
ExecutorService threadExecutor = Executors.newFixedThreadPool(3);
threadExecutor.execute(sw1); // start task1
threadExecutor.execute(sw2); // start task2
Upon running this, I get the following exception:
com.thoughtworks.selenium.SeleniumException: ERROR Server Exception: commandHolder got filled during execution of doCommandWithoutWaitingForAReponse
Any clues on what causes this?
Thanks.