Element Styles and HtmlStyle, GetStyle, GetComputedStyle
Telerik Testing Framework includes a good set of classes and methods for reading and validating the styles often attached to HTML controls. With this feature you can do things like:
Get a particular style and value from an element.
Get the cascaded style and value from an element.
Validate the color of a control.
Validate the margin setting of a control.
Convert an HTML color to a .NET ARGB color object.
Determine if the value of a style is a color.
Determine if the value of a style is an integer.
Let's look at some code samples to see how this works:
The GetComputedStyle is especially powerful. It will follow the CSS chain up through all the parent elements until it finds the first matching style and returns the value picked up from that style. This is quite different from GetStyle which only returns an explicitly set style value on the specific element (i.e. it does not follow the CSS chain). If no explicit value has been set then GetStyle returns an empty string for the value.
Here's an example: