title: How can I click this button in CasperJS?
body: <p>After some debugging, it appears I'm having difficulty either clicking or triggering the click event of this button within CasperJS:</p>
  
  <pre><code>&lt;a id="generate" class="btn" href="#generate"&gt;&lt;strong&gt;Generate&lt;/strong&gt;&lt;/a&gt;
  </code></pre>
  
  <p>Here's the code I have so far:</p>
  
  <pre>var casper = require('casper').create({
      clientScripts: [
          '...\\JQuery\\jquery-1.11.1.min.js'
      ],
      pageSettings: {
          userAgent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0'
      }
  });
  casper.on('page.initialized', function (page) {
      page.evaluate(function () {
          (function() {
              window.screen = {
                  width: 1600,
                  height: 900
              };
              var fake_nav = {};
              for (var i in navigator) {
                  fake_nav[i] = navigator[i];
              }
              fake_nav.javaEnabled = function() { return true; };
              fake_nav.language = 'en-US';
              window.navigator = fake_nav;
          })();
      });
  });
  casper.start('http://www.json-generator.com/', function() {
      this.echo("Loaded successfully.");
  });
  var template = '[\'{{repeat(1,3)}}\',    {asdf: "hello"}    ]';
  casper.then(function() {
      this.evaluate(function(input) {
          window.$('.CodeMirror')[0].CodeMirror.setValue(input);
       }, template);
  });
  casper.then(function() {
      this.evaluate(function() {
          document.$('#generate').click();
      });
  });
  casper.then(function() {
      var doc = this.evaluate(function($) {
          return window.$('.CodeMirror')[1].CodeMirror.getValue();
      });
      this.echo(doc);
  });
  casper.run(function() {
      this.echo('All Done.');
      this.exit();
  });
  </pre>
  
  <p>This generates the output (note the blank line from the "casper.echo(doc)"):</p>
  
  <pre>Loaded successfully.
  
  All Done.
  </pre>
  
  <p>I've confirmed that my javascript works in the browser console in both Chrome and Firefox. Why can't I click this button in CasperJS?</p>