Note that there are some explanatory texts on larger screens.

plurals
  1. POVS 2010 Coded UI Test Not Finding Window
    primarykey
    data
    text
    <p><strong>I couldn't get the SO text editor to mark parts of the post correctly so if you can trick SO into properly formatting the exception text and the code, that would be greatly appreciated.</strong></p> <p>Context:</p> <ul> <li>VS 2010 Premium</li> <li>Windows 7 Professional 32-bit edition</li> <li>VB .Net WinForms app named "Testing Testing"</li> <li>MSTest test project named "TestProject1" with a file named "CodedUITest1.vb"</li> <li>First created "CodedUITest1.vb" as part of the tutorial at <a href="http://blogs.msdn.com/b/mathew_aniyan/archive/2009/11/05" rel="nofollow">http://blogs.msdn.com/b/mathew_aniyan/archive/2009/11/05</a>.</li> </ul> <p>I took an existing coded UI test ("CodedUITest1.vb") and recorded an additional test using the test recorder provided by VS 2010.</p> <p>I also followed instructions from another SO post to make the "Testing Testing" executable launch and close as part of test initialization and cleanup respectively.</p> <p>However, now, when I run my unit tests, 2 instances of "Testing Testing.exe" launch and then I get the following exception:</p> <pre> > Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException was unhandled by user code BasicMessage=The playback failed to find the control with the given search properties. HResult=-268111872 Message=The playback failed to find the control with the given search properties. Additional Details: TechnologyName: 'MSAA' ControlType: 'Window' Name: 'Debug' ClassName: 'CabinetWClass' </pre> <p>CodedUITest1.vb:</p> <pre><code>'------------------------------------------------------------------------------ ' &lt;auto-generated&gt; ' This code was generated by coded UI test builder. ' Version: 10.0.0.0 ' ' Changes to this file may cause incorrect behavior and will be lost if ' the code is regenerated. ' &lt;/auto-generated&gt; ' ------------------------------------------------------------------------------ Imports System Imports System.CodeDom.Compiler Imports System.Collections.Generic Imports System.Drawing Imports System.Text.RegularExpressions Imports System.Windows.Input Imports Microsoft.VisualStudio.TestTools.UITest.Extension Imports Microsoft.VisualStudio.TestTools.UITesting Imports Microsoft.VisualStudio.TestTools.UITesting.WinControls Imports Microsoft.VisualStudio.TestTools.UnitTesting Imports Keyboard = Microsoft.VisualStudio.TestTools.UITesting.Keyboard Imports Mouse = Microsoft.VisualStudio.TestTools.UITesting.Mouse Imports MouseButtons = System.Windows.Forms.MouseButtons Namespace TestProject1 &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Partial Public Class UIMap '''&lt;summary&gt; '''TestAdd - Use 'TestAddParams' to pass parameters into this method. '''&lt;/summary&gt; Public Sub TestAdd() Dim uIDesktopList As WinList = Me.UIProgramManagerWindow.UIFolderViewWindow.UIDesktopList Dim uIItem7Button As WinButton = Me.UICalculatorWindow.UIItem7Window.UIItem7Button Dim uIItemButton As WinButton = Me.UICalculatorWindow.UIItemWindow.UIItemButton Dim uIItem2Button As WinButton = Me.UICalculatorWindow.UIItem2Window.UIItem2Button Dim uIItemButton1 As WinButton = Me.UICalculatorWindow.UIItemWindow1.UIItemButton 'Click 'Desktop' list box Mouse.Click(uIDesktopList, New Point(51, 491)) 'Launch '%windir%\System32\calc.exe' Dim uICalculatorWindow As ApplicationUnderTest = ApplicationUnderTest.Launch(Me.TestAddParams.UICalculatorWindowExePath, Me.TestAddParams.UICalculatorWindowAlternateExePath) 'Click '7' button Mouse.Click(uIItem7Button, New Point(6, 14)) 'Click '+' button Mouse.Click(uIItemButton, New Point(16, 14)) 'Click '2' button Mouse.Click(uIItem2Button, New Point(13, 11)) 'Click '=' button Mouse.Click(uIItemButton1, New Point(11, 27)) End Sub '''&lt;summary&gt; '''AssertSum - Use 'AssertSumExpectedValues' to pass parameters into this method. '''&lt;/summary&gt; Public Sub AssertSum() Dim uIItem9Text As WinText = Me.UICalculatorWindow.UIItem9Window.UIItem9Text 'Verify that '9' label's property 'DisplayText' equals '9' Assert.AreEqual(Me.AssertSumExpectedValues.UIItem9TextDisplayText, uIItem9Text.DisplayText) End Sub '''&lt;summary&gt; '''JustTyping - Use 'JustTypingParams' to pass parameters into this method. '''&lt;/summary&gt; Public Sub JustTyping() Dim uITypeEdit As WinEdit = Me.UIDebugWindow.UIItemWindow.UITestingTestingexeListItem.UITypeEdit Dim uITextBox1Edit As WinEdit = Me.UIForm1Window.UITextBox1Window.UITextBox1Edit 'Click 'Type' text box Mouse.Click(uITypeEdit, New Point(66, 6)) 'Type 'test' in 'TextBox1' text box uITextBox1Edit.Text = Me.JustTypingParams.UITextBox1EditText End Sub '''&lt;summary&gt; '''CheckingTheTextbox - Use 'CheckingTheTextboxExpectedValues' to pass parameters into this method. '''&lt;/summary&gt; Public Sub CheckingTheTextbox() Dim uITextBox1Edit As WinEdit = Me.UIForm1Window.UITextBox1Window.UITextBox1Edit 'Verify that 'TextBox1' text box's property 'Text' equals 'test' Assert.AreEqual(Me.CheckingTheTextboxExpectedValues.UITextBox1EditText, uITextBox1Edit.Text) End Sub #Region "Properties" Public Overridable ReadOnly Property TestAddParams() As TestAddParams Get If (Me.mTestAddParams Is Nothing) Then Me.mTestAddParams = New TestAddParams() End If Return Me.mTestAddParams End Get End Property Public Overridable ReadOnly Property AssertSumExpectedValues() As AssertSumExpectedValues Get If (Me.mAssertSumExpectedValues Is Nothing) Then Me.mAssertSumExpectedValues = New AssertSumExpectedValues() End If Return Me.mAssertSumExpectedValues End Get End Property Public Overridable ReadOnly Property JustTypingParams() As JustTypingParams Get If (Me.mJustTypingParams Is Nothing) Then Me.mJustTypingParams = New JustTypingParams() End If Return Me.mJustTypingParams End Get End Property Public Overridable ReadOnly Property CheckingTheTextboxExpectedValues() As CheckingTheTextboxExpectedValues Get If (Me.mCheckingTheTextboxExpectedValues Is Nothing) Then Me.mCheckingTheTextboxExpectedValues = New CheckingTheTextboxExpectedValues() End If Return Me.mCheckingTheTextboxExpectedValues End Get End Property Public ReadOnly Property UIProgramManagerWindow() As UIProgramManagerWindow Get If (Me.mUIProgramManagerWindow Is Nothing) Then Me.mUIProgramManagerWindow = New UIProgramManagerWindow() End If Return Me.mUIProgramManagerWindow End Get End Property Public ReadOnly Property UICalculatorWindow() As UICalculatorWindow Get If (Me.mUICalculatorWindow Is Nothing) Then Me.mUICalculatorWindow = New UICalculatorWindow() End If Return Me.mUICalculatorWindow End Get End Property Public ReadOnly Property UIDebugWindow() As UIDebugWindow Get If (Me.mUIDebugWindow Is Nothing) Then Me.mUIDebugWindow = New UIDebugWindow() End If Return Me.mUIDebugWindow End Get End Property Public ReadOnly Property UIForm1Window() As UIForm1Window Get If (Me.mUIForm1Window Is Nothing) Then Me.mUIForm1Window = New UIForm1Window() End If Return Me.mUIForm1Window End Get End Property #End Region #Region "Fields" Private mTestAddParams As TestAddParams Private mAssertSumExpectedValues As AssertSumExpectedValues Private mJustTypingParams As JustTypingParams Private mCheckingTheTextboxExpectedValues As CheckingTheTextboxExpectedValues Private mUIProgramManagerWindow As UIProgramManagerWindow Private mUICalculatorWindow As UICalculatorWindow Private mUIDebugWindow As UIDebugWindow Private mUIForm1Window As UIForm1Window #End Region End Class '''&lt;summary&gt; '''Parameters to be passed into 'TestAdd' '''&lt;/summary&gt; &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class TestAddParams #Region "Fields" '''&lt;summary&gt; '''Launch '%windir%\System32\calc.exe' '''&lt;/summary&gt; Public UICalculatorWindowExePath As String = "C:\Windows\System32\calc.exe" '''&lt;summary&gt; '''Launch '%windir%\System32\calc.exe' '''&lt;/summary&gt; Public UICalculatorWindowAlternateExePath As String = "%windir%\System32\calc.exe" #End Region End Class '''&lt;summary&gt; '''Parameters to be passed into 'AssertSum' '''&lt;/summary&gt; &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class AssertSumExpectedValues #Region "Fields" '''&lt;summary&gt; '''Verify that '9' label's property 'DisplayText' equals '9' '''&lt;/summary&gt; Public UIItem9TextDisplayText As String = "9" #End Region End Class '''&lt;summary&gt; '''Parameters to be passed into 'JustTyping' '''&lt;/summary&gt; &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class JustTypingParams #Region "Fields" '''&lt;summary&gt; '''Type 'test' in 'TextBox1' text box '''&lt;/summary&gt; Public UITextBox1EditText As String = "test" #End Region End Class '''&lt;summary&gt; '''Parameters to be passed into 'CheckingTheTextbox' '''&lt;/summary&gt; &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class CheckingTheTextboxExpectedValues #Region "Fields" '''&lt;summary&gt; '''Verify that 'TextBox1' text box's property 'Text' equals 'test' '''&lt;/summary&gt; Public UITextBox1EditText As String = "test" #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIProgramManagerWindow Inherits WinWindow Public Sub New() MyBase.New Me.SearchProperties(WinWindow.PropertyNames.Name) = "Program Manager" Me.SearchProperties(WinWindow.PropertyNames.ClassName) = "Progman" Me.WindowTitles.Add("Program Manager") End Sub #Region "Properties" Public ReadOnly Property UIFolderViewWindow() As UIFolderViewWindow Get If (Me.mUIFolderViewWindow Is Nothing) Then Me.mUIFolderViewWindow = New UIFolderViewWindow(Me) End If Return Me.mUIFolderViewWindow End Get End Property #End Region #Region "Fields" Private mUIFolderViewWindow As UIFolderViewWindow #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIFolderViewWindow Inherits WinWindow Public Sub New(ByVal searchLimitContainer As UITestControl) MyBase.New(searchLimitContainer) Me.SearchProperties(WinWindow.PropertyNames.ControlId) = "1" Me.WindowTitles.Add("Program Manager") End Sub #Region "Properties" Public ReadOnly Property UIDesktopList() As WinList Get If (Me.mUIDesktopList Is Nothing) Then Me.mUIDesktopList = New WinList(Me) Me.mUIDesktopList.SearchProperties(WinList.PropertyNames.Name) = "Desktop" Me.mUIDesktopList.WindowTitles.Add("Program Manager") End If Return Me.mUIDesktopList End Get End Property #End Region #Region "Fields" Private mUIDesktopList As WinList #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UICalculatorWindow Inherits WinWindow Public Sub New() MyBase.New Me.SearchProperties(WinWindow.PropertyNames.Name) = "Calculator" Me.SearchProperties(WinWindow.PropertyNames.ClassName) = "CalcFrame" Me.WindowTitles.Add("Calculator") End Sub #Region "Properties" Public ReadOnly Property UIItem7Window() As UIItem7Window Get If (Me.mUIItem7Window Is Nothing) Then Me.mUIItem7Window = New UIItem7Window(Me) End If Return Me.mUIItem7Window End Get End Property Public ReadOnly Property UIItemWindow() As UIItemWindow Get If (Me.mUIItemWindow Is Nothing) Then Me.mUIItemWindow = New UIItemWindow(Me) End If Return Me.mUIItemWindow End Get End Property Public ReadOnly Property UIItem2Window() As UIItem2Window Get If (Me.mUIItem2Window Is Nothing) Then Me.mUIItem2Window = New UIItem2Window(Me) End If Return Me.mUIItem2Window End Get End Property Public ReadOnly Property UIItemWindow1() As UIItemWindow1 Get If (Me.mUIItemWindow1 Is Nothing) Then Me.mUIItemWindow1 = New UIItemWindow1(Me) End If Return Me.mUIItemWindow1 End Get End Property Public ReadOnly Property UIItem9Window() As UIItem9Window Get If (Me.mUIItem9Window Is Nothing) Then Me.mUIItem9Window = New UIItem9Window(Me) End If Return Me.mUIItem9Window End Get End Property #End Region #Region "Fields" Private mUIItem7Window As UIItem7Window Private mUIItemWindow As UIItemWindow Private mUIItem2Window As UIItem2Window Private mUIItemWindow1 As UIItemWindow1 Private mUIItem9Window As UIItem9Window #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIItem7Window Inherits WinWindow Public Sub New(ByVal searchLimitContainer As UITestControl) MyBase.New(searchLimitContainer) Me.SearchProperties(WinWindow.PropertyNames.ControlId) = "137" Me.WindowTitles.Add("Calculator") End Sub #Region "Properties" Public ReadOnly Property UIItem7Button() As WinButton Get If (Me.mUIItem7Button Is Nothing) Then Me.mUIItem7Button = New WinButton(Me) Me.mUIItem7Button.SearchProperties(WinButton.PropertyNames.Name) = "7" Me.mUIItem7Button.WindowTitles.Add("Calculator") End If Return Me.mUIItem7Button End Get End Property #End Region #Region "Fields" Private mUIItem7Button As WinButton #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIItemWindow Inherits WinWindow Public Sub New(ByVal searchLimitContainer As UITestControl) MyBase.New(searchLimitContainer) Me.SearchProperties(WinWindow.PropertyNames.ControlId) = "93" Me.WindowTitles.Add("Calculator") End Sub #Region "Properties" Public ReadOnly Property UIItemButton() As WinButton Get If (Me.mUIItemButton Is Nothing) Then Me.mUIItemButton = New WinButton(Me) Me.mUIItemButton.SearchProperties(WinButton.PropertyNames.Name) = "Add" Me.mUIItemButton.WindowTitles.Add("Calculator") End If Return Me.mUIItemButton End Get End Property #End Region #Region "Fields" Private mUIItemButton As WinButton #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIItem2Window Inherits WinWindow Public Sub New(ByVal searchLimitContainer As UITestControl) MyBase.New(searchLimitContainer) Me.SearchProperties(WinWindow.PropertyNames.ControlId) = "132" Me.WindowTitles.Add("Calculator") End Sub #Region "Properties" Public ReadOnly Property UIItem2Button() As WinButton Get If (Me.mUIItem2Button Is Nothing) Then Me.mUIItem2Button = New WinButton(Me) Me.mUIItem2Button.SearchProperties(WinButton.PropertyNames.Name) = "2" Me.mUIItem2Button.WindowTitles.Add("Calculator") End If Return Me.mUIItem2Button End Get End Property #End Region #Region "Fields" Private mUIItem2Button As WinButton #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIItemWindow1 Inherits WinWindow Public Sub New(ByVal searchLimitContainer As UITestControl) MyBase.New(searchLimitContainer) Me.SearchProperties(WinWindow.PropertyNames.ControlId) = "121" Me.WindowTitles.Add("Calculator") End Sub #Region "Properties" Public ReadOnly Property UIItemButton() As WinButton Get If (Me.mUIItemButton Is Nothing) Then Me.mUIItemButton = New WinButton(Me) Me.mUIItemButton.SearchProperties(WinButton.PropertyNames.Name) = "Equals" Me.mUIItemButton.WindowTitles.Add("Calculator") End If Return Me.mUIItemButton End Get End Property #End Region #Region "Fields" Private mUIItemButton As WinButton #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIItem9Window Inherits WinWindow Public Sub New(ByVal searchLimitContainer As UITestControl) MyBase.New(searchLimitContainer) Me.SearchProperties(WinWindow.PropertyNames.ControlId) = "150" Me.WindowTitles.Add("Calculator") End Sub #Region "Properties" Public ReadOnly Property UIItem9Text() As WinText Get If (Me.mUIItem9Text Is Nothing) Then Me.mUIItem9Text = New WinText(Me) Me.mUIItem9Text.SearchProperties(WinText.PropertyNames.Name) = "Result" Me.mUIItem9Text.WindowTitles.Add("Calculator") End If Return Me.mUIItem9Text End Get End Property #End Region #Region "Fields" Private mUIItem9Text As WinText #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIDebugWindow Inherits WinWindow Public Sub New() MyBase.New Me.SearchProperties(WinWindow.PropertyNames.Name) = "Debug" Me.SearchProperties(WinWindow.PropertyNames.ClassName) = "CabinetWClass" Me.WindowTitles.Add("Debug") End Sub #Region "Properties" Public ReadOnly Property UIItemWindow() As UIItemWindow2 Get If (Me.mUIItemWindow Is Nothing) Then Me.mUIItemWindow = New UIItemWindow2(Me) End If Return Me.mUIItemWindow End Get End Property #End Region #Region "Fields" Private mUIItemWindow As UIItemWindow2 #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIItemWindow2 Inherits WinWindow Public Sub New(ByVal searchLimitContainer As UITestControl) MyBase.New(searchLimitContainer) Me.SearchProperties(WinWindow.PropertyNames.AccessibleName) = "Items View" Me.SearchProperties(WinWindow.PropertyNames.ClassName) = "DirectUIHWND" Me.WindowTitles.Add("Debug") End Sub #Region "Properties" Public ReadOnly Property UITestingTestingexeListItem() As UITestingTestingexeListItem Get If (Me.mUITestingTestingexeListItem Is Nothing) Then Me.mUITestingTestingexeListItem = New UITestingTestingexeListItem(Me) End If Return Me.mUITestingTestingexeListItem End Get End Property #End Region #Region "Fields" Private mUITestingTestingexeListItem As UITestingTestingexeListItem #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UITestingTestingexeListItem Inherits WinListItem Public Sub New(ByVal searchLimitContainer As UITestControl) MyBase.New(searchLimitContainer) Me.SearchProperties(WinListItem.PropertyNames.Name) = "Testing Testing.exe" Me.WindowTitles.Add("Debug") End Sub #Region "Properties" Public ReadOnly Property UITypeEdit() As WinEdit Get If (Me.mUITypeEdit Is Nothing) Then Me.mUITypeEdit = New WinEdit(Me) Me.mUITypeEdit.SearchProperties(WinEdit.PropertyNames.Name) = "Type" Me.mUITypeEdit.WindowTitles.Add("Debug") End If Return Me.mUITypeEdit End Get End Property #End Region #Region "Fields" Private mUITypeEdit As WinEdit #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UIForm1Window Inherits WinWindow Public Sub New() MyBase.New Me.SearchProperties(WinWindow.PropertyNames.Name) = "Form1" Me.SearchProperties.Add(New PropertyExpression(WinWindow.PropertyNames.ClassName, "WindowsForms10.Window", PropertyExpressionOperator.Contains)) Me.WindowTitles.Add("Form1") End Sub #Region "Properties" Public ReadOnly Property UITextBox1Window() As UITextBox1Window Get If (Me.mUITextBox1Window Is Nothing) Then Me.mUITextBox1Window = New UITextBox1Window(Me) End If Return Me.mUITextBox1Window End Get End Property #End Region #Region "Fields" Private mUITextBox1Window As UITextBox1Window #End Region End Class &lt;GeneratedCode("Coded UITest Builder", "10.0.30319.1")&gt; _ Public Class UITextBox1Window Inherits WinWindow Public Sub New(ByVal searchLimitContainer As UITestControl) MyBase.New(searchLimitContainer) Me.SearchProperties(WinWindow.PropertyNames.ControlName) = "TextBox1" Me.WindowTitles.Add("Form1") End Sub #Region "Properties" Public ReadOnly Property UITextBox1Edit() As WinEdit Get If (Me.mUITextBox1Edit Is Nothing) Then Me.mUITextBox1Edit = New WinEdit(Me) Me.mUITextBox1Edit.WindowTitles.Add("Form1") End If Return Me.mUITextBox1Edit End Get End Property #End Region #Region "Fields" Private mUITextBox1Edit As WinEdit #End Region End Class End Namespace </code></pre> <p>Helpful suggestions are welcome.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload