New to Telerik Test Studio? Download free 30-day trial

Getting and Setting Properties

We can also get and set the current value of any property of the wrapped element:

// Get whether a checkbox is enabled or disabled.
HtmlInputCheckBox cks = Find.ById<HtmlInputCheckBox>("checkbox1");
bool disabled = cks.GetValue<bool>("disabled");

// Disable it
cks.SetValue<bool>("disabled", true);
Assert.IsTrue(cks.GetValue<bool>("disabled"));

// Is it visible. IsVisible follows the CSS chain to determine if the
// element is actually visible or not. An element is visible when
// the CSS the display style is not 'none' and the visibility style
// is not 'hidden'.
Assert.IsTrue(cks.IsVisible());

// Get the color style
HtmlSpan mySpan = Find.ById<HtmlSpan>("Warning");
HtmlStyle styleColor = mySpan.GetStyle("color");
string strColor = mySpan.GetStyleValue("color");

// Getting the computed style will follow the CSS chain and return the
// style.
HtmlStyle styleMargin = mySpan.GetComputedStyle("margin");
string strMargin = mySpan.GetComputedStyleValue("margin");
In this article