CSS Selector equivalent of XPath - css

What is the CSS selector equivalent of XPath "//a[contains(text(),'Next ยป')]"?
Thanks

You cannot find text with CSS directly, you could set CSS properties via JavaScript based on the internal contents but in the end you would still need to be operating in the definitions of CSS.

Related

How to write css for element containing specific text?

I've an element with text List which I want to use. I can write xpath like -
//li[text()='List']
but instead of using xpath, I want to use css. How should I write css for it? I tried with following by referring https://saucelabs.com/resources/selenium/css-selectors but didn't work.
li:contains('List')
The CSS feature :contains('some text') is deprecated, you should only use xpath in your case. There is no way to do that using CSS

selenium - how to click on a link based on its text using css instead of xpath and without using the contains operator?

I try to use css locators over xpath when I can.
I have the following xpath locator that I would like to change to css:
//table[#id='service_schedule_sets']//a[text()='OptimalTest']
I would like to use a css locator. I wish to avoid using contains as there are support issues in later versions of css (i.e. contains was removed from css2 and css3 (css2 removal was a very last minute thing) that selenium covers up but I would like to avoid.
I am trying:
css=table#service_schedule_sets a[.='OptimalTest')
but it doesn't find the element.
The HTML is:
<td>
OptimalTest
</td>
Notes:
I want to use the text in the link ('OptimalTest') not the href.
I do not want to use link=OptimalTest approach as it is not specific enough.
CSS selectors do not support node selection based on their text content.
Actually there was a suggestion for a pseudo class :contains which would suit your needs, but it was removed from CSS 3 spec.

Apply CSS class in stylesheet

Is there a way to apply a class to a set of nodes matching a CSS selector, inside the actual stylesheet?
This is of course possible in a single line of jquery, but is it possible to do in the css itself?
input[type='button']
{
// apply the class 'k-button' to these
}
Is there a way to apply a class to a set of nodes matching a CSS selector, inside the actual stylesheet?
Nope, there's currently no way of doing that with standards compliant CSS.
No,there is not way of attach class with css,but you can use this code with jquery
$(".YourClassName").addClass("YourNewClass");
best regards
No, you can't do this with CSS. You're talking about altering markup, which CSS is really not designed to do (content: rules aside). As others have suggested, I would look into the 'extend' options in SASS, or use jQuery if need be.
That all being said - why can't you copy the relevant styles from the class declaration, and paste them into your selector? Or, just tack your selector on to the class declaration?

Auto-complete CSS property names for rule sets on Firebug?

On Firebug, when inspecting an element, is there a way to Auto-complete CSS property names for rule sets similarly to ctr+alt+space in some IDE for other languages?
No, it is not possible. But you can double click inside the class rules and start typing a CSS property name - Firebug will give you suggestions/autocompletion

Ruby: Computed Style for a webpage

I'm using Hpricot to parse an html page, but need to get the computed styles for each element. For example, if I have an h1 Hpricot element and the external CSS for the page has a background-image defined for h1's, how can I find out what the background-image is?
may be Selenium framework can help you?

Resources