title: Getting an HTML file after its javascript init methods loads in Java
body: <p>I have a Java code in which I want to load an HTML file and parse it. I am using <strong>jsoup</strong> library and everything is OK. </p>
  
  <p>The problem is when I GET the HTML resource, it takes some time with the page being loaded and completed, possibly some JavaScript code is running and fetching data from DB to put into HTML resource. </p>
  
  <p>But when getting the resource with Java, It does not wait for it to be completed and returns an HTML file with empty fields.</p>
  
  <p>I have tried the classic <strong>jsoup</strong> way:</p>
  
  <pre><code>Connection conn = Jsoup.connect("http://www.tsetmc.com/loader.aspx?ParTree=151311&amp;i=43362635835198978");
  Document doc = conn.get(); 
  String title = doc.title();
  System.out.println(title);
  </code></pre>
  
  <p>And <strong>WebClient</strong> package:</p>
  
  <pre><code>WebClient client = new WebClient(BrowserVersion.FIREFOX_60);
  client.waitForBackgroundJavaScriptStartingBefore(5000);
  HtmlPage page = client.getPage("http://www.tsetmc.com/loader.aspx?ParTree=151311&amp;i=43362635835198978");
  String pageTxt = page.asText();
  System.out.println(pageTxt);
  </code></pre>
  
  <p>But neither worked.</p>
  
  <p>How can I make my program wait until everything is complete?</p>