title: How to get the value of an attribute using XPath
body: <p>I have been testing using Selenium WebDriver and I have been looking for an XPath code to get the value of the attribute of an HTML element as part of my regression testing. But I couldn't find a good answer.</p>
  
  <p>Here is my sample html element:</p>
  
  <pre><code>&lt;div class="firstdiv" alt="testdiv"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I want to get the value of the "alt" attribute using the XPath. I have an XPath to get to the div element using the class attribute which is:</p>
  
  <pre><code>//div[@class="firstdiv"]
  </code></pre>
  
  <p>Now, I am looking for an XPath code to get the value of the "alt" attribute. The assumption is that I don't know what is the value of the "alt" attribute.</p>