title: Selenium C# Find Element with class and text
body: <p>im very new to testing and have no training in automated tests so please bare with me if i say stupid things but ill try the best i can.</p>
  <p>Bascially i am trying to assert that a specific employee in the employee list has the status of 'leaver'.</p>
  <p>This is what i have tried (and other variations with the different classes)</p>
  <pre><code>Assert.Equal(&quot;image-tile__badge background-color--status-leaver ng-star-inserted&quot;, Driver.FindElement(By.XPath(&quot;//*[contains(@class,'image-tile__content-header') and contains(text(),'End Date, Contract') and contains(@class, 'image-tile__badge')]&quot;)).GetAttribute(&quot;Class&quot;));
  
  Assert.Equal(&quot;image-tile__badge background-color--status-leaver ng-star-inserted&quot;, Driver.FindElement(By.XPath(&quot;//*[contains(@class,'image-tile__content-header') and contains(text(),'End Date, Contract')]&quot;)).FindElement(By.XPath(&quot;//*[contains(@class, 'image-tile__badge')]&quot;)).GetAttribute(&quot;Class&quot;));
         
  </code></pre>
  <p>The last one finds the element when the status is 'new', but when i change the employee status to 'leaver', it still returns as 'new' so possibly looking at another employee with a 'new' status.</p>
  <p>Hopefully this is enough info, let me know if more is needed (this is my first ever post!)
  HTML code in image below</p>
  <p>[HTML code on Chrome]
  [1]: <a href="https://i.stack.imgur.com/kUxkf.png" rel="nofollow noreferrer">https://i.stack.imgur.com/kUxkf.png</a></p>
  <p>Summary: im trying to assert that the Employee &quot;End Date, Contract&quot; has the status of leaver (aka the leaver class &quot;image-tile__badge background-color--status-leaver ng-star-inserted&quot;)</p>