title: Find elements by class name C# Selenium webdriver
body: <p>I'm new at C# and I'm trying to get elemnts by their class name. I found a way with the Xpath, but I'm sure there is more elegant and suitable solution to it.</p>
  
  <p>First I'm "grabbing" the table and then I'm finding the elements by Xpath. The thing I want to to do is to define one row. For example <code>entireRow</code> and through it to distribute the the different type of elements into two sums. If element is with class <code>"devColorLower"</code>,  <code>+=devColorLower</code> value,  if elements is with class <code>"devColorUpper"</code>, <code>++devColorUpper</code> value.</p>
  
  <p>Here is the code I use.</p>
  
  <pre><code>// Grab the table
  var tbody1 = driver.FindElements(By.XPath(".//*[@id='DataTableID']/tbody/tr"));
  
  // Grab the color values
  foreach (var row in tbody1)
  {
      var entireRow = row.FindElements(By.XPath(".//td"));
      var shortfall = row.FindElements(By.XPath(".//td[@class='DataTableTD devColorLower']")); 
      var exceedence = row.FindElements(By.XPath(".//td[@class='DataTableTD devColorUpper']"));
  }
  </code></pre>