Validation of Object Properties

2 posts, 1 answers
  1. Steve
    Steve avatar
    1885 posts
    Member since:
    Dec 2008

    Posted 13 Oct 2010 Link to this post

    Is there a way to validate an object to see if it contains a Property?
  2. Answer
    Cody
    Admin
    Cody avatar
    3354 posts

    Posted 14 Oct 2010 Link to this post

    Hello Steve,

    If you're talking about HTML elements, it's an attribute. This can't be done using a normal verification, but can easily be done in a coded step. Use code to verify an attribute is simply present on an element:

    bool found = false;
     
    foreach (iAttribute attr in Pages.Bing.PreferencesLink.Attributes)
    {
        if (attr.Name == "href")
        {
            found = true;
        }
    }
    Assert.IsTrue(found, "Attribut href not found");

    For Silverlight elements you can use code like this:

    Dictionary<string, string> props = Pages.TelerikTreeViewFor.SilverlightApp.InstallerTextblock.GetProperties();
    Assert.IsTrue(props.ContainsKey("Text"));

    Greetings,
    Cody
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top