I have been attempting to use selenium-webdriver to click on a specific element within a website, which happens to be plain text.
However, when I use the following javascript code
const spanElement = driver.findElement(By.css("span:contains('TEXT')"));
, it throws an error:
InvalidSelectorError: Given css selector expression "span:contains('TEXT')" is invalid: InvalidSelectorError: 'span:contains('TEXT')' is not a valid selector: "span:contains('TEXT')"
Interestingly, using Selenium IDE and
css=span:contains('Strategy Tester')
successfully finds the element.
- selenium-webdriver v3.6.0
- geckodriver
- firefox v60.0.2
What could I be overlooking in this situation?