ExecuteAutomation

Assertions in Coded UI Testing

In this post we will start our discussion about one of the most commonly used feature in coded UI testing as well as any testing for that matters, which is Assertions. According to Wikipedia, the definition of assertion is “An assertion is a predicate (a true–false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place. If an assertion evaluates to false at run-time, an assertion failure results, which typically causes execution to abort.” We have already discussed about working with assertions in coded UI test builder in our previous post, we also discussed the various methods available with Assert class as shown below In this post, we are going to discuss Some of the most commonly used assertion method like To understand some of the Assertion methods, we are going to write a custom method, which will get the text from text box, which we will then assert to check if the value is matching the expected value. You can watch the complete discuss in the video below Here is the complete code snippet for our GetText() method
public string GetText(string propertyvalue)
{
    HtmlEdit edit = new HtmlEdit(ParentWindow);
    edit.SearchProperties[HtmlEdit.PropertyNames.Name] = propertyvalue;
    return edit.GetProperty("Text").ToString();
}

Thanks for watching the video and reading the article. Please let me know if there is anything need to be improved in this article. Thanks, Karthik KK