title: Why doesn't plain JavaScript work in CasperJS?
body: <p>I'm new to CasperJS. How come <code>this.echo(this.getTitle());</code> works but <code>console.log("Page Title ", document.title);</code> doesn't? Also why isn't my document.querySelector working? Does anyone have a good explanation? Where in the CasperJS documentation can I find the answer?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>var casper = require('casper').create();
  var url = 'http://www.example.com/';
  
   casper.start(url, function() {
       this.echo(this.getTitle()); // works
       this.echo(this.getCurrentUrl()); // works
  });
  
  casper.then(function(){
      this.echo(this.getCurrentUrl()); // works
      console.log("this is URL: ", document.URL); // doesn't work
      console.log("Page Title ", document.title); // doesn't work
      var paragraph = document.querySelectorAll('p')[0].innerHTML;
      console.log(paragraph); // doesn't work
  });
  
  casper.run();
  </code></pre>
  
  <p><strong>EDIT:</strong>
  I'm using casper.thenEvaluate and casper.evaluate now and it's still not working. Any ideas?</p>
  
  <pre><code>var casper = require('casper').create();
  var url = 'http://www.example.com/';
  
  casper.start(url, function() {
      this.echo(this.getTitle()); // works
      this.echo(this.getCurrentUrl()); // works
      console.log('page loaded: '); // works
  });
  
  casper.thenEvaluate(function(){
      var paragraph = document.querySelectorAll('p')[0].innerHTML; // doesn't work
      console.log(paragraph); // doesn't work
      console.log("Page Title ", document.title); // doesn't work
  });
  
  casper.run();
  </code></pre>