Text in CSS selector

1,661 views
Skip to first unread message

Imrankhan

unread,
May 26, 2023, 8:31:00 AM5/26/23
to seleniu...@googlegroups.com
Hi all,

Good day ahead!

I have been trying to identify an element using CSS selector. But, I have been striving to use text like we do in XPATH. But, both text and innertext aren't working in the css selector. 

How can we identify an element through text in CSS selector?. 

Kindly help. 

--
Kind Regards,
Imrankhan M

David

unread,
May 27, 2023, 2:11:35 PM5/27/23
to Selenium Users
I don't think that's possible unless someone can correct me here. That's one of the shortcomings of CSS selectors. You might be able to though when combining it with javascript libraries like jQuery.

Raj Kumar

unread,
Oct 4, 2023, 12:13:54 AM10/4/23
to seleniu...@googlegroups.com
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.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/a2741f4e-4235-4c5c-80d2-1f9f0220fd98n%40googlegroups.com.

Serguei Kouzmine

unread,
Nov 7, 2023, 5:06:27 PM11/7/23
to Selenium Users

One can use Javascript  to do that search (querySelectorAll + text) Protractor  has  cssContainingText.js for long time . It can be used by Python , Java, .net wrappers available for a long time as well
Reply all
Reply to author
Forward
0 new messages