title: Using HTMLUnit to get javascript elements
body: <p>I'm trying to use HTMLUnit to get the javascript elements on a webpage (<a href="https://www.coursera.org/courses" rel="nofollow">https://www.coursera.org/courses</a>), and it is only loading the html data. How do I get it to display the information shown in the javascript container?</p>
  
  <p>Thanks!</p>
  
  <p>My current code:</p>
  
  <pre><code>     public String DownloadPage(String str){
      final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
      webClient.getOptions().setTimeout(20000);
      webClient.getOptions().setJavaScriptEnabled(true);
      webClient.getOptions().setThrowExceptionOnScriptError(false);
  
      try{
          HtmlPage page = webClient.getPage(str);
          XmlPage page2 = webClient.getPage(str);
          int n = webClient.waitForBackgroundJavaScript(100000); 
  
          System.out.println("Executing " + n + " JavaSript jobs!"); 
          System.out.println("OUTPUT: " + page2); 
  
          System.out.println("OUTPUT: " + page.asXml()); 
          webClient.closeAllWindows(); 
      }
  
      catch(IOException e){
          JOptionPane.showMessageDialog(null, "error");
      }
  
  
      webClient.closeAllWindows();
      return "";
  }
  </code></pre>