title: How to retrieve attribute of element in CasperJS using an XPath expression
body: <p>I have a webpage with this between lines:</p>
  
  <pre><code>&lt;a href="http://foo.com/home.do?SID=3443132"&gt;...
  </code></pre>
  
  <p>I need to extract "href" attribute using XPath. In the API of CasperJS is wrote this information about this: <a href="http://casperjs.org/api.html#clientutils.getElementByXPath" rel="nofollow">clientutils.getElementByXPath</a>.</p>
  
  <p>Here is my code:</p>
  
  <pre class="lang-js prettyprint-override"><code>phantom.casperPath = '..n1k0-casperjs-5428865';
  phantom.injectJs(phantom.casperPath + '\\bin\\bootstrap.js');
  
  var casper = require('casper').create();
  
  var url = "...";
  
  casper.start(url, function() {
  casper.echo("started");
  });
  
  var x = require('casper').selectXPath;           
  
  casper.then(function() 
  {
  casper.echo("getsid");  
      this.test.assertExists(x('//a[contains(@href, "home.do?SID=")]'), 'the element exists');
  var element = __utils__.getElementByXPath('//a[contains(@href, "home.do?SID=")]');    
  });
  </code></pre>
  
  <p>But it fails. it returns this:</p>
  
  <pre><code>false
  undefined
  started
  getsid
  PASS the element exists  &lt;== XPATH WORKS
  FAIL ReferenceError: Can't find variable: __utils__
  #    type: uncaughtError
  #    error: "ReferenceError: Can't find variable: __utils__"
  ReferenceError: Can't find variable: __utils__
  </code></pre>