title: Phantom.js - Get Text Inside Alert Box
body: <p>Is it possible to get the text inside an alert box using Phantom.js?</p>
  
  <pre><code>var page = require("webpage").create()
  , assert = require("assert");
  
  page.open("http://www.mysite.com/page", function (status) {
    page.includeJs("jquery-1.10.2.min.js", function () {
      var alertText = page.evaluate(function () {
        //This should cause an alert dialog to appear
        $('button[type="submit"]').click();
  
        //This doesn't work, but is there some equivalent to this?
        return $("alert").val();
      });
  
      assert.equal(alertText, "Thanks for clicking Submit!");
    });
  });
  </code></pre>