It is not possible.
Selenium CSS Selectors do not support locating elements based on their text content.
See this or this or other similar questions about that.

Answer from Prophet on Stack Overflow
🌐
Javatpoint
javatpoint.com › selenium-css-selector-inner-text
Selenium CSS Selector - Inner text - javatpoint
Selenium Selenium IDE is divided ... will look at the features and functionalities of... ... CSS Selector - Attribute Syntax: css=<HTML tag><[attribute=Value of attribute]> We can use value, type and name as an Attribute to create a CSS Selector....
Discussions

java - CSS Locator with contains() InvalidSelectorException using Selenium WebDriver - Stack Overflow
Well that is the point I wanted to confirm. I was trying the locators from the IDE and the one I used was not working. BTW, I picked up the list from saucelabs.com/resources/selenium/css-selectors (Inner Text) and thought they were applicable for webdriver scripting as well. More on stackoverflow.com
🌐 stackoverflow.com
selenium - Does CSS Selector have contains text similar to xpath? - Stack Overflow
In Selenium, are there any options for CSS selectors with "contains" similar to Xpath where we check with contains[text(),....]. In the following example, I have given the CSS and Xpath &... More on stackoverflow.com
🌐 stackoverflow.com
selenium - A way to match on text using CSS locators - Software Quality Assurance & Testing Stack Exchange
12 Is jQuery faster than CSS/Xpath selectors for IE 8.0 in Selenium1? 5 Selenium - Find exact text match using CSS locators More on sqa.stackexchange.com
🌐 sqa.stackexchange.com
May 10, 2011
Css locator with Innertext with Selenium Webdriver - Stack Overflow
In a webpage that I want to automate, getting few results with a class search as below for Css. .all_message-min_text The matching node results that I got are, currently, only 2 as below. More on stackoverflow.com
🌐 stackoverflow.com
October 16, 2017
🌐
Google Groups
groups.google.com › g › selenium-users › c › SEMa-ytXgYs
Text in CSS selector
May 26, 2023 - We can't do that. We cannot identify elements using text in the CSS selector. To do that, you'll have to use an XPath. Thanks & Regards Raj Kumar Mobile: - +1 6026934946 ... -- You received this message because you are subscribed to the Google Groups "Selenium Users" group.
🌐
BrowserStack
browserstack.com › home › guide › mastering selenium css selectors in 2026
CSS Selector in Selenium: Locate Elements with Examples | BrowserStack
December 10, 2025 - CSS Selectors in Selenium allows to match a partial String with the help of various symbols to represent the start, end and contents inside a text.
🌐
Software Testing Help
softwaretestinghelp.com › home › selenium automation › selenium – css selector for identifying web elements
Selenium - CSS Selector for Identifying Web Elements
May 9, 2025 - For Example, let’s again consider “Password textbox”, so the corresponding CSS Selector would be: ... The inner text helps us identify and create CSS Selector using a string pattern that the HTML Tag manifests on the web page.
🌐
Guru99
guru99.com › home › selenium › css selector in selenium
CSS Selector in Selenium
April 24, 2025 - Selenium IDE should be able to access the Password label as shown in the image below. Step 3) This time, replace the inner text with “Boston” so that your Target will now become “css=font:contains(“Boston”)”. Click Find. You should notice that the “Boston to San Francisco” label becomes highlighted.
🌐
QACRAFT -
qacraft.com › home › selenium testing › css selector in selenium
Css Selector in Selenium - QACRAFT
June 21, 2022 - 5) Inner Text: Utilizing inner text distinguishes and makes CSS Selectors in Selenium WebDriver by using a string design that the HTML Tag appears on the site page.
Find elsewhere
🌐
Tutorial and Example
tutorialandexample.com › css-selector-inner-text
CSS Selector: Inner text in Selenium IDE - TAE
November 16, 2019 - CSS Selector: Inner text in Selenium IDEwith tutorial and examples on HTML, CSS, JavaScript, XHTML, Java, .Net, PHP, C, C++, Python, JSP, Spring, Bootstrap, jQuery, Interview Questions etc. - TAE
🌐
Stack Overflow
stackoverflow.com › questions › 46771875 › css-locator-with-innertext-with-selenium-webdriver
Css locator with Innertext with Selenium Webdriver - Stack Overflow
October 16, 2017 - Selenium CSS Locator for span text inside nested divs · 1 · Find element by exact text within the exact element using css selector · 0 · CSS element locator · 1 · How to use CSS locator with tag + class name + inner html text to identify ...
🌐
Thedeveloperblog
thedeveloperblog.com › selenium › selenium-css-selector-inner-text
Selenium CSS Selector - Inner text
Selenium CSS Selector - Inner text with Introduction, features, selenium basic terminology, what is selenium, selenium limitations, selenium vs qtp, tool suite, selenium ide, ide-installation, ide-features, ide-first test case, ide-commands, ide-creating test cases manually, ide-login test etc.
🌐
The Test Tribe
thetesttribe.com › home › automation › css selectors in selenium explained (with examples)
CSS Selectors in Selenium Explained (with Examples) - The Test Tribe
April 2, 2025 - These selectors are helpful when dealing with dynamic attributes where only part of the value remains constant. The Inner Text Selector finds elements based on their visible text content.
🌐
Thedigitalgroup
blog.thedigitalgroup.com › locator-strategies-in-selenium-webdriver-css-selectors
Locator Strategies in Selenium WebDriver: CSS selectors | T/DG Blog - Digital Thoughts
This is right now not supported by WebDriver in case of CSS, but most probably will support in upcoming Selenium 3 or 4. Syntax: css= tag:contains(‘inner text’), Here in syntax we can use any combination discussed above.
🌐
TutorialsArena
tutorialsarena.com › fundamentals › selenium › selenium-css-selector-inner-text
CSS Selectors: Using the :contains() Pseudo-class for Text-Based Element Selection
August 10, 2024 - This selects any element of the specified element type that contains the exact text string provided within the contains() pseudo-class. Note that this selector is not part of standard CSS and might not be supported in all browsers or testing ...
🌐
Tpoint Tech
tpointtech.com › selenium-css-selector-inner-text
Selenium CSS Selector - Inner text - Tpoint Tech
March 17, 2025 - 5-IDE- Locating by CSS · a)Locating by ID · b)Locating by Class · c)Locating by Attribute · d)Locating by ID/Class & Attribute · e)Locating by Sub-string · f)Locating by inner text · 6-IDE- Locating by DOM · Selenium WebDriver · WebDriver Vs RC · WebDriver-Installation ·
🌐
Besant Technologies
besanttechnologies.com › home › blogs › general › css selectors in selenium
CSS Selectors in Selenium | Using CSS Selectors in Selenium Webdriver
January 14, 2020 - Let us look at some of the CSS Selector sample types: The exact string patterns that an HTML tag displays in a web page is called the inner text.
🌐
Packtpub
subscription.packtpub.com › book › programming › 9781849515740 › 1 › ch01lvl1sec16 › locating-elements-using-text
Locating Elements | Selenium Testing Tools Cookbook
This will locate the <td> element matching with exact text. CSS selector and XPath provide methods with which to locate elements based on their text contents.