SoWhat
SoWhat

Reputation: 5622

Xpath selector for class

I want to get the Xpath selector for classname(.class) . So basically, i want to know how I can select [attr~=value]

So if i have an element

<div class="class1 class2 class3"></div>
<div class="class1"></div>

I want to select .class1, it should return both the divs. [@class='class1'] doesn't work since it won't select the first div.

Upvotes: 4

Views: 807

Answers (1)

d1rk
d1rk

Reputation: 1956

That trick should only find "class1":

//div[contains(concat(' ',normalize-space(@class),' '),' class1 ')]

Upvotes: 6

Related Questions