If I read the specification correctly, no.
You can match on an element, the name of an attribute in the element, and the value of a named attribute in an element. I don't see anything for matching content within an element, though.
Answer from Dean J on Stack OverflowIf I read the specification correctly, no.
You can match on an element, the name of an attribute in the element, and the value of a named attribute in an element. I don't see anything for matching content within an element, though.
Looks like they were thinking about it for the CSS3 spec but it didn't make the cut.
:contains() CSS3 selector http://www.w3.org/TR/css3-selectors/#content-selectors
selenium - A way to match on text using CSS locators - Software Quality Assurance & Testing Stack Exchange
CSS selector for all elements with same text content
CSS attribute selector to find any word/text in a page and apply CSS.
CSS selector (id contains part of text) - Stack Overflow
Videos
css=a[text='Log Out'] or a[innertext='Log Out']
Can you please try this one out?
Or if that doesn't work and you still don't want to use xpath because it's slow, you can always try: link=Log Out. That's still better then xpath.
EDIT:
So i found a possible solution for you mate. If you are trying to find an exact String you could always use Regular expression like this:
css=div:contains("^ab$")
Just replace div with a and there you go. This will find ONLY AB in whatever text div it looks for. OFC if you have more then one links with text AB (which is a bad thing :P ) then it will find them all..
Try this and see if it helps. :)
This is a nice place for a few CSS selectors.
http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/
Thought it might be useful for people following this thread.
I have buttons on a page with the same text content "Edit".
What CSS selector to use to style them all?
Here is an example...
<button onclick="o('10178','e')">Edit</button>
<button onclick="o('6915','e')">Edit</button>
<button onclick="o('2800','e')">Edit</button>I tried this, but it didn't work...
button[text()='Edit']
Hey guys,
I can't seem to remember what the CSS selector or CSS in general that lets you apply CSS to a particlar word or phrase on a document. Not a class per say but anywhere the word or phrase may be.
For example, wherever it may say "Do not apply" or "achtung" font-weight:700 ; text-decoration: underline;
I've done it a while back but I can't recall.
Thanks in advance.
Try this:
a[id*='Some:Same'][id$='name']
This will get you all a elements with id containing
Some:Same
and have the id ending in
name
<div id='element_123_wrapper_text'>My sample DIV</div>
The Operator ^ - Match elements that starts with given value
div[id^="element_123"] {
}
The Operator $ - Match elements that ends with given value
div[id$="wrapper_text"] {
}
The Operator * - Match elements that have an attribute containing a given value
div[id*="123_wrapper"] {
}