title: How do I extract a specific attribute from a list of elements that are all the same
body: <p>Our company has a report that shows bar graphs. The color of all the bars are gray except for 2 bars that are blue and green respectively as seen below:</p>
  
  <p><a href="https://i.stack.imgur.com/Wuqu8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wuqu8.png" alt="Bar Graph"></a></p>
  
  <p>Here is what the elements look like:</p>
  
  <p><a href="https://i.stack.imgur.com/hWGvY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hWGvY.png" alt="Bar Graph Elements"></a></p>
  
  <p>Now the blue and green graphs can appear anywhere on the x-axis.
  I am writing my selenium test cases in C# and I want to check that the highlighted elements are present on the page. </p>
  
  <p>Here is how I've defined my element selector variable </p>
  
  <pre><code>private readonly By barGraphAverage = By.CssSelector("rect[fill='#0373bc']");
  </code></pre>
  
  <p>and I wrote a method to check if that element exists</p>
  
  <pre><code>public string getBarGraph()
  {
      return base.Browser.FindElementOrNull(barGraphAverage).Text;
  }
  </code></pre>
  
  <p>This is how I'm calling it in my test class</p>
  
  <pre><code>Assert.IsTrue(getBarGraph());
  </code></pre>