{"id":5993,"date":"2011-10-28T02:16:00","date_gmt":"2011-10-28T02:16:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2011\/10\/28\/coded-ui-test-extension-for-3rd-party-controls-the-basics-explained\/"},"modified":"2022-07-27T03:10:38","modified_gmt":"2022-07-27T11:10:38","slug":"coded-ui-test-extension-for-3rd-party-controls-the-basics-explained","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/coded-ui-test-extension-for-3rd-party-controls-the-basics-explained\/","title":{"rendered":"Coded UI Test Extension for 3rd party controls &#8211; the basics explained"},"content":{"rendered":"<p>Having developed a 3rd party control, wonder what it takes to go from NO support to <strong>FULL<\/strong> support for Coded UI Test? How to make the UI elements testable by Coded UI Test \u2013 to be able to create automated tests from manual recording, record user actions, generate code from user actions, add custom code to UI Tests and finally run those coded UI Tests?<\/p>\n<p>Well it could be accomplished by step-by-step implementation with each step allowing access to rich features of Coded UI Test as shown below. All of this can be accomplished by leveraging the extension points of Coded UI Test framework.<\/p>\n<p><img decoding=\"async\" style=\"padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px\" title=\"clip_image002\" border=\"0\" alt=\"clip_image002\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2011\/10\/5633.clip_image002_thumb_44AE3EF0.jpg\" width=\"644\" height=\"368\" \/><\/p>\n<p>Fig 1: Shows four steps needed to get from NO support to FULL Coded UI support<\/p>\n<p><strong><span style=\"font-size: small\">Level 1: Basic Record and Playback<\/span><\/strong><\/p>\n<p><strong><em>Without<\/em><\/strong><\/p>\n<p>1&#46; Recorder records co-ordinate clicks and does not recognize element in the UI hierarchy. As a result, tests would fail when application window is resized or when control is not in view during test run<\/p>\n<p>2&#46; Validation tests on control properties is not possible as recorder does not recognize the element object<\/p>\n<p>\u00a0<strong><em>With<\/em><\/strong><\/p>\n<p>1&#46; Recorder records co-ordinate click, sends a request to Technology Abstraction Layer (TAL) to identify the element from co-ordinate point. TAL retrieves element information from the appropriate plugin depending upon control support level and returns the element information to the recorder<\/p>\n<p>2&#46; Navigation possible amongst siblings or parents or children<\/p>\n<p>3&#46; Validation of basic control properties are now possible<\/p>\n<p>4&#46; Can extend control code to get to Level 1; no plugins required<\/p>\n<p>\u00a0<img decoding=\"async\" style=\"padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2011\/10\/3566.image_thumb_40142037.png\" width=\"644\" height=\"389\" \/><\/p>\n<p>Fig 2: Shows that Coded UI Test Builder crosshair identifies a cell inside a GridView and exposes basic cell properties if Level 1 is implemented<\/p>\n<p><strong><span style=\"font-size: small\">Level 2: Rich Property Validation<\/span><\/strong><\/p>\n<p><strong><em>Without<\/em><\/strong><\/p>\n<p>1&#46; User not able to add assertion on custom properties of controls<\/p>\n<p>2&#46; Playback engine would not be able to validate custom properties of controls during test run<\/p>\n<p>\u00a0<strong><em>With<\/em><\/strong><\/p>\n<p>1&#46; User can add assertion on custom properties<\/p>\n<p>2&#46; Playback engine validates properties during test run<\/p>\n<p>3&#46; Extend <em>PropertyProvider<\/em> and add plugin<\/p>\n<p>\u00a0<img decoding=\"async\" style=\"padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2011\/10\/5280.image_thumb_3827CDFC.png\" width=\"644\" height=\"389\" \/><\/p>\n<p>Fig 3: Shows how custom properties such as BackColor\/ForeColor\/BorderColor of Cell can be exposed through extension thus enabling assertion if Level 2 is implemented<\/p>\n<p><strong><span style=\"font-size: small\">Level 3: Code Generation<\/span><\/strong><\/p>\n<p><strong><em>Without<\/em><\/strong><\/p>\n<p>1&#46; Objects and properties of auto-generated test code are derived from the base class of UI Test framework \u2013 UITestControl\u00a0<\/p>\n<p><img decoding=\"async\" style=\"padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2011\/10\/0842.image_thumb_2F73E365.png\" width=\"1044\" height=\"253\" \/><\/p>\n<p>Fig 4: Shows that auto-generated code on cell click is registered on default cell object &#8211; WinCell<\/p>\n<p><strong><em>With<\/em><\/strong><\/p>\n<p>1&#46; Specialized classes can be written for each control<\/p>\n<p>2&#46; Auto-generated test code is more readable and maintainable<\/p>\n<p>3&#46; Extend <em>PropertyProvider<\/em> and add plugin\u00a0<\/p>\n<p><img decoding=\"async\" style=\"padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2011\/10\/5545.image_thumb_599F7D4E.png\" width=\"1044\" height=\"253\" \/><\/p>\n<p>Fig 5: Shows that auto-generated code on a Cell click is registered on custom object \u2013 GridViewCellInfo if Level 3 is implemented<\/p>\n<p><strong><span style=\"font-size: small\">Level 4: Intent Aware Actions<\/span><\/strong><\/p>\n<p><strong><em>Without<\/em><\/strong><\/p>\n<p>1&#46; Recorder records all mouse clicks and keyboard inputs<\/p>\n<p>2&#46; Recordings not linked to control behavior<\/p>\n<p>3&#46; E.g. Set \u201cTom Scott\u201d in table cell recorded as Click Cell \u2013> Click Cell (to enable editing) \u2013> Edit Text on edit box although the extra click is not relevant and final intent is to set cell value instead of text box\u00a0<\/p>\n<p><img decoding=\"async\" style=\"padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2011\/10\/8666.image_thumb_61930BB1.png\" width=\"1044\" height=\"379\" \/><\/p>\n<p>Fig 6: Set \u201cTom Scott\u201d in table cell recorded as Click Cell \u2013> Click Cell (to enable editing) \u2013> Type \u201cTom Scott\u201d in text box<\/p>\n<p><strong><em>With<\/em><\/strong><\/p>\n<p>1&#46; Recorder aggregates actions on action stack based on filter rules in Action Filter<\/p>\n<p>2&#46; Can record only intended steps based on control behavior<\/p>\n<p>3&#46; E.g. Set \u201cTom Scott\u201d in table cell recorded as Click Cell \u2013> Type \u201cTom Scott\u201d on cell<\/p>\n<p>4&#46; Extend *ActionFilter *and add plugin\u00a0<\/p>\n<p><img decoding=\"async\" style=\"padding-left: 0px;padding-right: 0px;padding-top: 0px;border-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2011\/10\/4643.image_thumb_60F66755.png\" width=\"1044\" height=\"323\" \/><\/p>\n<p>Fig 7: Set \u201cTom Scott\u201d in table cell recorded as Click Cell \u2013> Type \u201cTom Scott\u201d on cell if Level 4 is implemented<\/p>\n<p>Having added implementation for all the above levels, a control developer can claim FULL Coded UI Support. However, most Coded UI Test features could be used just by implementing Level 1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having developed a 3rd party control, wonder what it takes to go from NO support to FULL support for Coded UI Test? How to make the UI elements testable by Coded UI Test \u2013 to be able to create automated tests from manual recording, record user actions, generate code from user actions, add custom code [&hellip;]<\/p>\n","protected":false},"author":103,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229,1,252],"tags":[],"class_list":["post-5993","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-community","category-devops","category-testing"],"acf":[],"blog_post_summary":"<p>Having developed a 3rd party control, wonder what it takes to go from NO support to FULL support for Coded UI Test? How to make the UI elements testable by Coded UI Test \u2013 to be able to create automated tests from manual recording, record user actions, generate code from user actions, add custom code [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/5993","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/103"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=5993"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/5993\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=5993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=5993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=5993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}