CSS selector (identifier contains part of the text)

I have a question. I have elements something like this:

<a> element with id = someGenerated Some: Same: 0: name

<a> element with id = someGenerated Some: Same: 0: last name

<a> element with id = someGenerated Some: Same: 1: name

<a> element with id = someGenerated Some: Same: 1: last name

I need a CSS selector to get names. The problem is that I do not know how to get this. I tried a[id*='Some:Same'] - it returned all the <a> elements. After I get the elements whose id ends with a name. But I do not like this idea. I think this can be done using another selector.

+76
css css-selectors webdriver
Aug 28 '12 at 8:55
source share
3 answers

Try the following:

 a[id*='Some:Same'][id$='name'] 

This will give you all elements a with an identifier containing

Some: Same

and id ends in

name

+115
Aug 28 '12 at 10:24
source share

The only selector that I see is a[id$="name"] (all links with id end with "name"), but this does not limit it as it should.

+8
Aug 28 2018-12-12T00:
source share
 <div id='element_123_wrapper_text'>My sample DIV</div> 

^ Operator - match elements that begin with a given value

 div[id^="element_123"] { } 

Operator $ - matches elements ending with a given value

 div[id$="wrapper_text"] { } 

* Operator - matches elements that have an attribute containing a given value

 div[id*="wrapper_text"] { } 
0
May 08 '19 at
source share



All Articles