david hol
david hol

Reputation: 1280

Get span text using CSS Selector (with xpath this works fine)

So i have this element:

<span class="clas">Create new form</span>

And i want to get this elemen:

span:contains('Create new') 

Why this is not working ?

Upvotes: 0

Views: 4318

Answers (1)

ddavison
ddavison

Reputation: 29092

Based on your selector, I assume that you are trying to use the :contains() CSS pseudo-class selector, which has been removed from the CSS3 spec. This won't work because the latest browsers conform to the new CSS standards.

If the class attribute for this specific element is unique, then you can use:

span.clas

If not, then you are forced to use xpath:

//span[contains(text(), 'Create new')]

Upvotes: 1

Related Questions