Can anyone assist me in finding elements based on their class and the text they contain? I have attempted the following methods without success, so any guidance would be greatly appreciated (I prefer using CSS for selection, but XPath is also acceptable):
Driver.FindElement(By.XPath("//td[contains(@class,'TestClass') and .//text()='TestText']"))
Driver.FindElement(By.CssSelector("td.TestClass:contains('TestText')"))
Sample elements to locate:
<td class="TestClass"> TestText</td>
<td class="TestClass"> TestText1</td>
<td class="TestClass"> TestText2</td>...