VS 2010编码UI测试未找到窗口

时间:2010-11-10 01:44:31

标签: vb.net visual-studio-2010

我无法使用SO文本编辑器正确标记帖子的部分内容,因此如果您可以欺骗SO以正确格式化异常文本和代码,那将非常感激。

上下文:

  • VS 2010 Premium
  • Windows 7 Professional 32位版
  • VB .Net WinForms应用程序名为“Testing Testing”
  • 名为“TestProject1”的MSTest测试项目,其文件名为“CodedUITest1.vb”
  • 首先在http://blogs.msdn.com/b/mathew_aniyan/archive/2009/11/05的教程中创建了“CodedUITest1.vb”。

我使用现有的编码UI测试(“CodedUITest1.vb”)并使用VS 2010提供的测试记录器记录了一个额外的测试。

我还按照另一个SO帖子的说明进行“测试测试”可执行文件的启动和关闭,分别作为测试初始化​​和清理的一部分。

但是,现在,当我运行单元测试时,启动了2个“Testing Testing.exe”实例,然后我得到以下异常:

> 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'

CodedUITest1.vb:

'------------------------------------------------------------------------------
'  <auto-generated>
'      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.
'  </auto-generated>
' ------------------------------------------------------------------------------

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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    Partial Public Class UIMap

        '''<summary>
        '''TestAdd - Use 'TestAddParams' to pass parameters into this method.
        '''</summary>
        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

        '''<summary>
        '''AssertSum - Use 'AssertSumExpectedValues' to pass parameters into this method.
        '''</summary>
        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

        '''<summary>
        '''JustTyping - Use 'JustTypingParams' to pass parameters into this method.
        '''</summary>
        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

        '''<summary>
        '''CheckingTheTextbox - Use 'CheckingTheTextboxExpectedValues' to pass parameters into this method.
        '''</summary>
        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

    '''<summary>
    '''Parameters to be passed into 'TestAdd'
    '''</summary>
    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    Public Class TestAddParams

        #Region "Fields"
        '''<summary>
        '''Launch '%windir%\System32\calc.exe'
        '''</summary>
        Public UICalculatorWindowExePath As String = "C:\Windows\System32\calc.exe"

        '''<summary>
        '''Launch '%windir%\System32\calc.exe'
        '''</summary>
        Public UICalculatorWindowAlternateExePath As String = "%windir%\System32\calc.exe"
        #End Region
    End Class

    '''<summary>
    '''Parameters to be passed into 'AssertSum'
    '''</summary>
    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    Public Class AssertSumExpectedValues

        #Region "Fields"
        '''<summary>
        '''Verify that '9' label's property 'DisplayText' equals '9'
        '''</summary>
        Public UIItem9TextDisplayText As String = "9"
        #End Region
    End Class

    '''<summary>
    '''Parameters to be passed into 'JustTyping'
    '''</summary>
    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    Public Class JustTypingParams

        #Region "Fields"
        '''<summary>
        '''Type 'test' in 'TextBox1' text box
        '''</summary>
        Public UITextBox1EditText As String = "test"
        #End Region
    End Class

    '''<summary>
    '''Parameters to be passed into 'CheckingTheTextbox'
    '''</summary>
    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    Public Class CheckingTheTextboxExpectedValues

        #Region "Fields"
        '''<summary>
        '''Verify that 'TextBox1' text box's property 'Text' equals 'test'
        '''</summary>
        Public UITextBox1EditText As String = "test"
        #End Region
    End Class

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
    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

欢迎提供有用的建议。

1 个答案:

答案 0 :(得分:0)

    <GeneratedCode("Coded UITest Builder", "10.0.30319.1")>  _
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

如果查看构造函数的最后一行,它会向WindowTitles列表添加一个字符串。此字符串是您进行操作录制时选择的窗口的名称。

如果WindowsTitle已更改,您将遇到问题,因为程序使用该字符串来确定执行操作的窗口。因此,如果您的窗口标题已更改,请从“计算器”更改为“程序管理器” ,您必须确保适当地更改WindowTitle。例如:

Me.UICalculatorWindow.WindowTitles.Clear();
Me.UICalculatorWindow.WindowTitles.Add("type new window title here");

这样,当您的编码ui测试尝试执行操作时,例如点击链接,它就知道要在哪个窗口中查找链接。