<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="www.w3.org/2005/Atom" xmlns:sy="purl.org/rss/1.0/modules/syndication/" xmlns:dc="purl.org/dc/elements/1.1/" xmlns:content="purl.org/rss/1.0/modules/content/" xmlns:wfw="wellformedweb.org/CommentAPI/" xmlns:slash="purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Deepak Singhal - MSFT</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/dpksinghal/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/dpksinghal/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:39:47 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How to test deep hierarchy controls using Coded UI Test in WPF?</title>
      <link>https://docs.microsoft.com/archive/blogs/dpksinghal/how-to-test-deep-hierarchy-controls-using-coded-ui-test-in-wpf</link>
      <pubDate>Wed, 28 Sep 2011 08:53:00 GMT</pubDate>
      <dc:creator><![CDATA[Deepak.Singhal [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dpksinghal/2011/09/28/how-to-test-deep-hierarchy-controls-using-coded-ui-test-in-wpf/</guid>
      <description><![CDATA[In June 2011 we released an hot fix (KB2544407)&nbsp;addressing several issues that our customers...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: small;">In June 2011 we released an hot fix (<span id="ctl00_MasterBody_TitleValue">KB2544407)</span>&nbsp;addressing several issues that our customers are facing while using testing tools in Visual Studio 2010 Service Pack1. In that list one was related to Coded UI testing for WPF controls that are deep in hierachy. Following is the detailed information about the issue and how it is being fixed by the hot fix.</span></p>
<p><span style="text-decoration: underline;"><strong><span style="font-size: small;">Some important links:</span></strong></span></p>
<ul>
<li>
<div style="padding-left: 30px;"><span style="font-size: small;">Brief information of all the issues fixed in the hotfix can be found <a href="https://blogs.msdn.com/b/lab_management/archive/2011/06/23/new-qfe-for-visual-studio-2010-testing-tools.aspx">here</a>. </span></div>
</li>
<li>
<div style="padding-left: 30px;"><span style="font-size: small;"><span style="font-size: small;">Download link for the hotfix can be found <a href="https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=36847">here</a>. </span></span></div>
</li>
</ul>
<p><span style="font-size: medium;"><b><span style="text-decoration: underline;">Problem statement:</span></b></span></p>
<p>In WPF a control may be present under a different control at any nested level. In Coded UI Test we look for 2 levels up from control&rsquo;s immediate ancestor [parent of the control in Coded UI Test] to see if there is any container control [e.g., Tab, ListBox, DataGrid]. If we don&rsquo;t find it within 2 levels, no container control will be included in the Query ID. This will be an issue during playback, as we do not search inside a container control if it is not part of the Query ID for performance reasons. So if a container control exists above 2 or more levels from the control user acted on, playback will fail to find that control. The reason for going only 2 levels up to find the container control during recording is to void the performance impact and this number is chosen based on the testing done on real world applications scenarios. But we have been seeing going up to 2 levels is not sufficient some time. User may have some control which is nested at more than 2 levels deep under a container control.</p>
<p><span style="font-size: medium;"><b><span style="text-decoration: underline;">What is the fix:</span></b></span></p>
<p>So to fix this, we have exposed a configuration key named &lsquo;MaxLevelsForItemContainer&rdquo; so that user can define the maximum level he is interested to look for an item container control in WPF applications. User can define this key in CodedUITestBuilder.exe.config/MTM.exe.config file as shown below. If the following key does not exist the default value still be 2 only.&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp; &lt;add key="MaxLevelsForItemContainer" value="&lt;desiredLevel&gt;"/&gt;</p>
<p><span style="font-size: small;"><b><span style="text-decoration: underline;">How a user can figure out the no of levels:</span></b></span></p>
<p>In the sample application provided in this article, the hierarchy for the check box controls present inside the group items will be like as follows</p>
<table style="border: 1px solid #000000; width: 547px; height: 854px; padding-left: 90px;" border="1" rules="all" frame="border" align="left">
<tbody>
<tr>
<td style="text-align: center;"><strong><span style="font-size: small;">Actual UI</span></strong></td>
</tr>
<tr>
<td><img style="margin-right: auto; margin-left: auto; display: block;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/6574.pic.png" original-url="blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-08/6574.pic.png" width="440" height="562" /></td>
</tr>
<tr style="height: 10px;">
<td>
<p align="center"><strong><span style="font-size: small;">UI hierarchy [using UISpy tool]</span></strong></p>
</td>
</tr>
<tr>
<td><img style="margin-right: auto; margin-left: auto; display: block;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/3755.pic1.png" original-url="blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-08/3755.pic1.png" width="537" height="210" /></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The container control [tab] is 3 levels up from the parent [group &lsquo;flower1&rsquo;] of the check box. If you try to record actions on the checkbox or create an assertion for the properties of checkbox control, following will be the hierarchy in Coded UI Test [picked up from Coded UI Test builder].</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/0728.pic2.png" original-url="blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-08/0728.pic2.png"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/0728.pic2.png" original-url="blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-08/0728.pic2.png" width="500" height="214" /></a></p>
<p>So it is clear from the above hierarchy that CheckBox control&rsquo;s hierarchy does not have information related to tab item and tab control hence it is bound to fail when user runs the through Coded UI Test or Microsoft Test Manager.</p>
<p>Reason being while generating the hierarchy for the checkbox control, the recorder looks up to 2 levels from checkbox&rsquo;s parent i.e., UIFlower1Group and hence no container control is found it comes out and the above hierarchy is generated.</p>
<p><span style="font-size: medium;"><b><span style="text-decoration: underline;">Solution:</span></b></span></p>
<p>To fix the above issue, user first should try to find the max no of levels recorder should look up for container control using UISpy tool, in this case it is 3 [Flower1 (group)=&gt; Flowers (group) =&gt; OnlineStore (TabItem) =&gt; Tab], and then update the<br />CodedUITestBuilder.exe.config or MTM.exe.config based on user&rsquo;s need. A sample config file for CodedUITestBuilder.exe is attached within this article. <br />Following key should be added in config file under &lt;appsettings&gt; node.</p>
<p>&nbsp;&nbsp;&nbsp; &lt;add key="MaxLevelsForItemContainer" value="3"/&gt;</p>
<p>Once the above is done, restart the CodedUITestBuilder and do the same action again on checkbox. This time user can see the complete hierarchy present for the control as shown below.</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/0871.pic3.png" original-url="blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-08/0871.pic3.png"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/0871.pic3.png" original-url="blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-42-08/0871.pic3.png" width="505" height="248" /></a></p>
<p>&nbsp;</p>
<p>I have attached the sample configuration file for Coded UI Test builder and a sample application to reproduce the issue mentioned in the blog post. Users can use them to understand it better.</p>
<p>To understand more about WPF plugin in Visual Studio 2010 AFN and property validation refer the following deep dive sections on WPF support:</p>
<p style="padding-left: 30px;"><a href="https://blogs.msdn.com/vstsqualitytools/archive/2010/04/13/uitest-framework-wpf-plugin-part-1.aspx">blogs.msdn.com/vstsqualitytools/archive/2010/04/13/uitest-framework-wpf-plugin-part-1.aspx</a></p>
<p style="padding-left: 30px;"><a href="https://blogs.msdn.com/vstsqualitytools/archive/2010/04/13/uitest-framework-wpf-plugin-part-2.aspx">blogs.msdn.com/vstsqualitytools/archive/2010/04/13/uitest-framework-wpf-plugin-part-2.aspx</a></p>
<p>Happy testing!!!</p>
<p>Regards,</p>
<p>Deepak.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/21/77/08/WPFDeepHierarchyControl.zip" original-url="blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-21-77-08/WPFDeepHierarchyControl.zip">WPFDeepHierarchyControl.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>How to: Validate properties of nested controls in Silverlight</title>
      <link>https://docs.microsoft.com/archive/blogs/dpksinghal/how-to-validate-properties-of-nested-controls-in-silverlight</link>
      <pubDate>Wed, 24 Nov 2010 05:44:54 GMT</pubDate>
      <dc:creator><![CDATA[Deepak.Singhal [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dpksinghal/2010/11/24/how-to-validate-properties-of-nested-controls-in-silverlight/</guid>
      <description><![CDATA[In Silverlight a UI designer can have nested controls inside a simple control to improve the...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">In Silverlight a UI designer can have nested controls inside a simple control to improve the experience. For example in the below XAML, I have put an image and some text along with it inside a button control (highlighted).</span></span><code class="js"><br /><br /></code></p>
<p class="MsoNormal"><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">Button</span><span style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt"> Height</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">="23"</span><span style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt"> HorizontalAlignment</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">="Left"</span><span style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt"> Margin</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">="78,22,0,0"</span><span style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt"> Name</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">="button3"</span><span style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt"> VerticalAlignment</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">="Top"</span><span style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt"> Width</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">="139"&gt;</span><span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&lt;</span><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">Button.Content</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&gt;</span><span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&lt;</span><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">StackPanel</span><span style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt"> Orientation</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">="Horizontal"</span><span style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt"> Width</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">="124"&gt;</span><span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">&lt;</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-highlight: yellow">Image</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: red; FONT-SIZE: 9.5pt; mso-highlight: yellow"> Source</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">="/SilverlightApplication3;component/user.jpg"</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: red; FONT-SIZE: 9.5pt; mso-highlight: yellow"> Width</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">="30"&gt;&lt;/</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-highlight: yellow">Image</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">&gt;</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; FONT-SIZE: 9.5pt; mso-highlight: yellow"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">&lt;</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-highlight: yellow">TextBlock</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: red; FONT-SIZE: 9.5pt; mso-highlight: yellow"> Width</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">="70"</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: red; FONT-SIZE: 9.5pt; mso-highlight: yellow"> HorizontalAlignment</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">="Left"</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: red; FONT-SIZE: 9.5pt; mso-highlight: yellow"> TextAlignment</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">="Center"&gt;</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-highlight: yellow">Install</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">&lt;/</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: #a31515; FONT-SIZE: 9.5pt; mso-highlight: yellow">TextBlock</span><span style="FONT-FAMILY: Consolas; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 9.5pt; mso-highlight: yellow">&gt;</span><span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&lt;/</span><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">StackPanel</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&gt;</span><span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&lt;/</span><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">Button.Content</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&gt;</span><span style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&lt;/</span><span style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">Button</span><span style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;</span></o:p><span style="font-size: small;"><span style="font-family: Calibri;">In designer you will see the following hierarchy for the above xaml code.</span></span></p>
<p class="MsoNormal"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/4263.ControlHierarchy.png" original-url="blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-08/4263.ControlHierarchy.png" border="0" /></span></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Following will be the actual control appearing in the Silverlight UI.</span></span><v:shape o:spid="_x0000_i1026" type="#_x0000_t75" id="Picture_x0020_2" style="width: 127.5pt; height: 33pt;"><v:imagedata src="file:///C:\Users\dsinghal\AppData\Local\Temp\msohtmlclip1\01\clip_image003.png" o:href="cid:image002.png@01CB8BC4.C2465070"><span style="font-family: Calibri; font-size: small;"></span></v:imagedata></v:shape><o:p></o:p></p>
<p class="MsoNormal"><o:p><span style="font-family: Calibri; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/7180.ControlView.png" original-url="blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-08/7180.ControlView.png" border="0" /></span></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Now there can be some testing scenarios on the UI Button as such:<o:p></o:p></span></span></p>
<ol>
<li>
<div class="MsoListParagraph"><span style="font-size: small;"><span style="font-family: Calibri;">Validating the text on the button<o:p></o:p></span></span></div>
</li>
<li>
<div class="MsoListParagraph"><span style="font-size: small;"><span style="font-family: Calibri;">Validating the file name or some other properties of the image control.<o:p></o:p></span></span></div>
</li>
</ol>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">By default if you try to locate this button control using Coded UI Test builder, you will see Silverlight button but its properties will not be good enough to cater the above needs (highlighted).</span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"></span></span><o:p><span style="font-family: Calibri; font-size: small;"><span style="font-family: Calibri; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/5102.CUITB.png" original-url="blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-08/5102.CUITB.png" border="0" />&nbsp;</span></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">The reason for the above is the nested control hierarchy of the button control and to get the right set of properties one needs to access button&rsquo;s children i.e., image and the text. To do that click on the down arrow as shown in the highlighted circle. You&rsquo;ll be able to check Image properties after first reaching the first child of button as follows.</span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;"></span></span><o:p><span style="font-family: Calibri; font-size: small;"><span style="font-family: Calibri; font-size: small;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/42/08/1323.CUITB1.png" original-url="blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-42-08/1323.CUITB1.png" border="0" />&nbsp;</span></o:p></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">Similar way now going to right will reach you to the text control for any further validation.<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">In the same way you can add validations for other type of nested controls e.g., Hyperlink, labels, button having other controls inside it (checkbox), list box having images + text. Following is a link to download a sample where I have created these kind of controls and the test project along with it has validations added for these controls.</span></span></p>
<p class="MsoNormal"><span style="font-size: small;"><span style="font-family: Calibri;">The attachment has one interesting example of list box where list items are represented as a comboination of Graphic and list item. This <a target="_blank" href="https://blogs.msdn.com/b/tapas_sahoos_blog/archive/2010/11/16/why-does-selection-of-an-item-getting-recorded-as-a-mouse-click-action.aspx">blogpost</a> can tell you the reason behind this and how Coded UI Test handles this.</span></span></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/10/09/60/32/SampleSLAppForNestedControls.zip" original-url="blogs.msdn.com/cfs-file.ashx/__key/communityserver-components-postattachments/00-10-09-60-32/SampleSLAppForNestedControls.zip">SampleSLAppForNestedControls.zip</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>