How To: Add assertions in Coded UI Tests

Syed Aslam Basha here from the Information Security Tools Team.

As continuation to my previous post, let me show adding check point which is adding assertions to coded UI test scripts.

For example, after launching portal site you want to validate user name.

  • Press enter after this.UIMap.LaunchPortalSite(); (continuation from the previous blog post) , right click and select first option “use coded UI test builder”
  • image
  • Click on cross hair (third button) and drag and drop on the control you want to validate
  • image
  • Add assertions form will be shown, you can navigate through the controls and reach the top most control or form and see its properties. You can add assertion to any of the properties shown.
  • image
  • Right click on the inner text which we are interested in and click on add assertion
  • image
  • Select comparator and comparison value and click on Ok
  • image
  • Click on generate code button. Enter appropriate method name say ValidateUser and you are ready to validate the user name.

-Syed Aslam Basha ( syedab@microsoft.com )

Microsoft Information Security Tools (IST) Team

Test Lead

---------------------------------------------------------

Please leave a comment if the blog post has helped you.