Reputation: 18547
I want to select the div
with class "bmBidderButtonText"
and with "Low"
as inner text, what should I do?
<div class="bmBidderButtonText"><div class="bmBidderButtonArrow"></div>Low</div>
<div class="bmBidderButtonText"><div class="bmBidderButtonArrow"></div>High</div>
Merely //div[@class="bmBidderButtonText"]
will select two divs, but how should I include the "Low" as inner text as condition within the xpath?
Upvotes: 1
Views: 14718
Reputation: 18612
You can use contains()
for this reason:
//div[contains(text(), 'Low')]
Additional resources:
Upvotes: 0
Reputation: 2611
Try this below xpath
//div[@class='bmBidderButtonText'][text() ='Low']
Explanation:- Use class
attribute of <div>
tag along with the text
method.
Upvotes: 1
Reputation: 89325
You can use .
to reference current context element, so implementing additional criteria of "...and with 'Low' as inner text" in XPath would be as simple as adding and .='Low'
in the predicate of your initial XPath :
//div[@class="bmBidderButtonText" and .="Low"]
Upvotes: 2
Reputation: 18799
use and
:
//div[@class="bmBidderButtonText" and contains(., "Low")]
Upvotes: 0