I was trying to locate table column containing text 'Name', and it fails while using cssSelector
with 'Unable to locate element'
but works with XPath.
I tried all the 3 below options with different browsers but it throws error:
driver.findElement(By.cssSelector("td:contains('Name')"));
driver.findElement(By.cssSelector("td[textContent = 'Name']"));
driver.findElement(By.cssSelector("td[innerText = 'Name']"));
Whereas same can be located by XPath:
driver.findElement(By.xpath("//td[contains(text(),'Name')]"));
Can anyone explain please why it is failing for the css and is there anything which I am missing out?