title: How to follow automatic form submitting and redirection using nightmarejs (or casperjs/phantomjs)
body: <p>Using nightmarejs, I'd like follow several redirection and automatic form submitting, which is invoked by the page script. And want to get the last page.</p>
  
  <p>For instance, the page content of <code>http://myexample/</code> like this:</p>
  
  <pre><code>&lt;html&gt;&lt;body&gt;
  &lt;form action="http://somewhere/" method="post"&gt;
    &lt;!-- some params --&gt;
  &lt;/form&gt;
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $('form').submit();
  &lt;/script&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>The script element of this page submits the form. And the post request to <code>http://somewhere/</code> is sent. And then <code>http://somewhere/</code> returns 302 response to <code>http://another/</code>.</p>
  
  <p>To get the last page (<code>http://another/</code>), I tried nightmarejs code like this:</p>
  
  <pre><code>var Nightmare = require('nightmare');
  new Nightmare()
      .goto('http://myexample/')
      .wait(1000)
      .url(function(url) {
          console.log(url);
      })
      .evaluate(function () {
          return window.location.href;
      }, function (res) {
          console.log(res);
      })
      .run();
  </code></pre>
  
  <p>I tried <code>url</code> and <code>evaluate</code> methods but I could not get last page.</p>
  
  <p>Is there a way to support the case like this? The answer using casperjs or phantomjs are also welcome.</p>
  
  <h2>UPDATE</h2>
  
  <p>I've tried PhanomJS and been able to follow redirects. But there was another problem that connection fails by <code>SSL Handshake failed</code> error. I've solved this to add <code>--ssl-protocol=any</code> option. </p>