[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Validation code can analyze the results of a test to determine whether the application performed as expected without the need for human intervention.
Right-click inside your coded UI test method, point to Edit CodedUITest, and then click Use the UI Control Locator.
When you use the UI Control Locator tool to add validation, the UI control for this UI test control must be visible in your application under test. If it is not visible, the UI Control Locator will be unable to locate the control.
If your UI control is already listed in the Add Assertion tab of the Coded UI Test Builder dialog box, click to select that UI control.
If your UI control is not listed:
Click Launch Locator to Add UI Controls.
Use the crosshairs to select the UI control in your application.
Click Add Control.
Click Close.
Click to select your UI control.
To display the properties that you can validate for this UI test control, click Show Properties to Add Assertions or press F4.
Select the properties that you want to validate, and then select the comparator operation and the comparison value for each property.
To generate the validation code for the selected properties, click OK.
This adds the code for the Assert statement into the test method.
If the comparison in the Assert statement fails when the test runs, then the test will fail.
You can also add Assert statements manually to your code to validate properties of UI test control. For example, to compare if the expected value equals the actual value of testElement1:
string testElementValue = testElement1.GetProperty("Value").ToString(); Assert.AreEqual(expectedValue, testElementValue);