title: Getting PhantomJS to work with a java application
body: <p>I am testing around with PhantomJS a bit.</p>
  
  <p>But I am not sure how to make it work with a java application, th examples I have found are mostly just against files or sites.</p>
  
  <p>So this is what I have now.</p>
  
  <pre><code> var page = require('webpage').create();
  
   address = "http://localhost:8080/logon.do";       
  
  page.open(address, function(status) {
      wait(5000);
        if (status !== 'success') {
          console.log('Unable to access network');
      } else {
          var ua = page.evaluate(function () {
              return document.getElementsByTagName('html')[0].outerHTML;
          });
          console.log(ua);
      }
        phantom.exit();
  
  });
  
  
  function wait(ms){
     var start = new Date().getTime();
     var end = start;
     while(end &lt; start + ms) {
       end = new Date().getTime();
    }
  }
  </code></pre>
  
  <p>Now I know this wait is ugly but it is not important right now.
  The server is running and if I go to the url I get a log in page.
  I was expecting this log in page to be the output of console.log(ua);
  Instead I get the output: 
  &lt;-html>&lt;-head>&lt;-/head>&lt;-body>&lt;-/body>&lt;-/html></p>
  
  <p>What am I missing?</p>