I'm using Selenium WebDriver 3.11.0 and Chrome 66 and trying to retrieve element using following css selectors which are based on text of the element -
1.
WebElement element = driver.findElement(By.cssSelector("h3:contains('File Downloader')"));
2
WebElement element = driver.findElement(By.cssSelector("h3[text='File Downloader']"));
3
WebElement element = driver.findElement(By.cssSelector("h3[innertext='File Downloader']"));
It gives following error for #1:
org.openqa.selenium.InvalidSelectorException: invalid selector: An invalid or illegal selector was specified
while #2 and #2 are unable to locate element(NoSuchElementException)
Following is the HTML for the element -
<h3>File Downloader</h3>
Is it something that css is not supporting retrieving element based on text? I want to understand what has changed now because in many posts, I can see all above three ways were recommended for retrieving elements based on text in css selector.