I'm using Java htmlunit 2.24 library. Is there anyway to find out that any JavaScript has actually finished executing on an HTML page (HtmlPage)?
Yes there is....
final JavaScriptJobManager tmpJobManager = aHtmlPage.getEnclosingWindow().getJobManager();
int tmpJobCount = tmpJobManager.getJobCount();
if (tmpJobCount > 0) {
.....
}
If you are interested in more details you can have a look at the Wetator (http://www.wetator.org/) source code (https://wetator.repositoryhosting.com/trac/wetator_wetator/browser/trunk/wetator/src/org/wetator/backend/htmlunit/HtmlUnitBrowser.java)