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.
Using C#, .Net 4.5, and Selenium 2.45
Use findElements to capture firstdiv elements into a collection.
var firstDivCollection = driver.findElements(By.XPath("//div[@class='firstdiv']"));
Then iterate over the collection.
foreach (var div in firstDivCollection) { div.GetAttribute("alt"); }