title: CasperJS HTTP Authentication
body: <p>cannot deal with simply HTTP authentication. Here's my code:</p>
  
  <pre><code>var x = require('casper').selectXPath;
  var casper = require('casper').create({
      verbose: false,
      logLevel: 'debug'
  });
  casper.options.viewportSize = {width: 1366, height: 667};
  casper.start('https://example.com/a/dashboard');
  casper.setHttpAuth('username', 'password');
  
  casper.then(function() {
      this.test.assertUrlMatch(/^https:\/\/example.com\/a\/dashboard$/);
  });
  
  casper.run(function() {this.test.renderResults(true);});
  </code></pre>
  
  <hr>
  
  <p>And error that I see in console:</p>
  
  <pre><code>casperjs mytest.js
  FAIL Current url matches the provided pattern
  #    type: assertUrlMatch
  #    subject: false
  #    currentUrl: "https://example.com/login"
  #    pattern: "/^https:\\/\\/example.com\\/a\\/dashboard$/"
  FAIL 1 tests executed in 2.428s, 0 passed, 1 failed.
  </code></pre>
  
  <hr>
  
  <p>Q: Why my current Url does't match with pattern?
  Thank you.</p>