Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I need CSS selector to select elements that contain a given text

Line:

<div class="btn btn-second-in-pair-not-desired btn-tall">Clear search</div>
<div class="btn btn-second-in-pair-not-desired btn-tall">Raw Search</div>
<div class="btn btn-second-in-pair-not-desired btn-tall">Basic Search</div>
<div class="btn btn-primary-stand-alone btn-tall search-btn">Search</div>

Here is what i have tried so far - ".btn:contains('Clear search')" but selenium is not able to catch it

like image 434
user3121891 Avatar asked Sep 16 '25 06:09

user3121891


1 Answers

CSS Selector doesn't support :contains() anymore. You have to use XPath "//div[text()='Clear search']".

like image 128
Buaban Avatar answered Sep 17 '25 22:09

Buaban