次の方法で共有


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.

Comments

  • Anonymous
    July 12, 2011
    I am confused with different assertion options like should i put an assertion on Innertext, friendlyname, displaytext etc? and for comparator should I use areequal , contains or matches? which one is for what ? thanks

  • Anonymous
    July 12, 2011
    and adding assertions how would i know that they are passing successfully? when i run the test in debug mode it does go through those steps but it doeant show anything on UI?

  • Anonymous
    August 05, 2011
    Example if (this.UIMap.CheckIfReviewIsActiveExpectedValues.UIAsdreviewisActiveYouPaneInnerText.Contains("You cannot start the wizard process when the review is active")) //        Do something...

  • Anonymous
    August 05, 2011
    Decide on what you want to verify and which property gives you the control and validate Operators are straight forward are equal checks if both expected and actual are equal decide based on your requirement See below example