1

How to check operations like Greater Than, Less Than while doing CodedUI Testing using Assert Function?

I am working on Visual Studio 2010 Ultimate.

1
  • Is my answer helpful? do you need more information? Commented Jan 26, 2016 at 11:06

1 Answer 1

1

You can add any other custom assertion you want by customizing the code. Follow following steps

First Add any assertion on your property and generate code for Validation Method.

Move the Validation Method to UIMap.cs from UIMap.Designer.cs

Now Customize the code in UIMap.cs in the Validation Method. Here is an example:

/// <summary>
/// Verifies that the result count is > the min value passed.
/// </summary>
public void VerifyMinimumResultCount(int minResultCount)
{
    HtmlSpan totalResults =
        this.ApplicationWindow.
        IntermediateParent.TotalResultsTextBox;

    // Use regular expression to get the text out of the
    // Control Property.
    int actualResultCount;
    Match resultPattern = Regex.Match(totalResults.Text,
        "[0-9]+-[0-9]+ of ([0-9,]*) results");
    Assert.IsTrue(resultPattern.Success,
        "Regular expression match failed");
    Assert.IsTrue(int.TryParse(resultPattern.Groups[1].Value,
                  NumberStyles.Number,
                  CultureInfo.CurrentCulture,
                  out actualResultCount),
                  "Parsing failed");
    Assert.IsTrue(actualResultCount >= minResultCount,
          "Got less than expected min result");
}

Or you can use the AssertTrue :

//...
int expectedValueLimit = 2;
int actualValue = int.Parse(myUiControl.text);
Assert.IsTrue((actualValue > expectedValueLimit), "myUiControl value is less than " + expectedValueLimit);
//...

Source: https://social.msdn.microsoft.com/Forums/en-US/da835e54-598b-4f3d-a5bf-6c4d1ea32de6/codedui-greater-than-assertion?forum=vsautotest

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.