Reputation: 779
example: Can I just if a div tag has the css of
div{background-color: #444444}
and return true/false depending on the result?
I'm using watir webdriver to run testing scripts, I need to check values of css to and see if the changes have been applied etc.
Upvotes: 0
Views: 1230
Reputation: 46836
Watir-webdriver has a built in style
method for getting the computed styles.
Get the style using:
div.style('background-color')
This will return a string representing the computed style's value. You can then compare that to your expected value.
Upvotes: 2
Reputation: 7054
You may try something like this with Javascript:
var bg = document.defaultView.getComputedStyle(yourElement).getPropertyValue('background-color');
if (bg == '#444444'){
// do your code here
}
You may need to check this for older browsers.
Upvotes: 0
Reputation: 624
You need to mix Nokogiri (HTML parser) and CSSPool (CSS parser) to looks for the style and for any element with that selector in the body.
Upvotes: 0