Hi, I am new to the visual studio CodedUITesting. I created a few automated tests, 2 of the tests passed and 1 test failed with the following error message:
-----------------------------------------------------------------------Error Message-----------------------------------------------------------------------
Test method CodedUITestProject.CodedUITest1.NewRole threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'MSAA'
ControlType: 'Table'
Name: 'dgvRoles'
AccessibleDescription: 'Business Roles'
---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
Result StackTrace:
at Microsoft.VisualStudio.TestTools.UITest.Playback.Engine.IScreenElement.FindAllDescendants(String bstrQueryId, Object& pvarResKeys, Int32 cResKeys, Int32 nMaxDepth)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindAllScreenElement(String queryId, Int32 depth, Boolean singleQueryId, Boolean throwException, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITest.Playback.ScreenElement.FindScreenElement(String queryId, Int32 depth, Boolean resetSkipStep)
at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.FindFirstDescendant(String queryId, Boolean expandUIElementWhileSearching, Int32 searchTime)
--- End of inner exception stack trace ---
-----------------------------------------------------------------------Error Message -----------------------------------------------------------------------
I don't understand what the error means and thus do not know how to fix it.
This is what my code looks like. I think it fails on the bold text because it does not type the text “Admin” into the first column. Could you please give me some advice on what to do or how to fix this issue?
<TestMethod()>
Public Sub NewRole()
Me.UIMap.StartupApp_LoginToMain()
Me.UIMap.OpenRoleForm()
Me.UIMap.NewRole()
End Sub
'''<summary>
'''StartupApp_LoginToMain - Use 'StartupApp_LoginToMainParams' to pass parameters into this method.
'''</summary>
Public Sub StartupApp_LoginToMain()
Dim uIOpenComboBox As WinComboBox = Me.UIRunWindow.UIItemWindow.UIOpenComboBox
Dim uIOKButton As WinButton = Me.UIRunWindow.UIOKWindow.UIOKButton
Dim uISettingsButton As WinButton = Me.UILoginWindow.UISettingsWindow.UISettingsButton
Dim uITxtServerEdit As WinEdit = Me.UIConnecttoadatabaseWindow.UICELESTEZPCSQLEXPRESSWindow.UITxtServerEdit
Dim uITxtDataEdit As WinEdit = Me.UIConnecttoadatabaseWindow.UIIT3AGWindow.UITxtDataEdit
Dim uIOKButton1 As WinButton = Me.UIConnecttoadatabaseWindow.UIOKWindow.UIOKButton
Dim uIOKButton2 As WinButton = Me.UIConnectionStateWindow.UIOKWindow.UIOKButton
Dim uITxtNameEdit As WinEdit = Me.UILoginWindow.UITxtNameWindow.UITxtNameEdit
Dim uITxtPassEdit As WinEdit = Me.UILoginWindow.UITxtPassWindow.UITxtPassEdit
Dim uIOKButton3 As WinButton = Me.UILoginWindow.UIOKWindow.UIOKButton
'Press keyboard shortcut keys 'Windows + r'
Keyboard.SendKeys(Me.StartupApp_LoginToMainParams.SendKeys, ModifierKeys.Windows)
'Select 'c:\tfs\IT3\DEV\IT3\IT3C\bin\Debug\IT3C.exe' in 'Open:' combo box
uIOpenComboBox.EditableItem = Me.StartupApp_LoginToMainParams.UIOpenComboBoxEditableItem
'Click 'OK' button
Mouse.Click(uIOKButton, New Point(23, 19))
'Click '&Settings' button
Mouse.Click(uISettingsButton, New Point(59, 14))
'Type 'CELESTEZ-PC\SQLEXPRESS' in 'txtServer' text box
uITxtServerEdit.Text = Me.StartupApp_LoginToMainParams.UITxtServerEditText
'Type '{Tab}' in 'txtServer' text box
Keyboard.SendKeys(uITxtServerEdit, Me.StartupApp_LoginToMainParams.UITxtServerEditSendKeys, ModifierKeys.None)
'Type 'IT3AG' in 'txtData' text box
uITxtDataEdit.Text = Me.StartupApp_LoginToMainParams.UITxtDataEditText
'Click '&OK' button
Mouse.Click(uIOKButton1, New Point(100, 18))
'Click 'OK' button
Mouse.Click(uIOKButton2, New Point(27, 12))
'Type 'SuperU' in 'txtName' text box
uITxtNameEdit.Text = Me.StartupApp_LoginToMainParams.UITxtNameEditText
'Type '{Tab}' in 'txtName' text box
Keyboard.SendKeys(uITxtNameEdit, Me.StartupApp_LoginToMainParams.UITxtNameEditSendKeys, ModifierKeys.None)
'Type '********' in 'txtPass' text box
Keyboard.SendKeys(uITxtPassEdit, Me.StartupApp_LoginToMainParams.UITxtPassEditSendKeys, true)
'Click '&OK' button
Mouse.Click(uIOKButton3, New Point(54, 18))
End Sub
'''<summary>
'''OpenRoleForm
'''</summary>
Public Sub OpenRoleForm()
Dim uIItemTabPage As UITestControl = Me.UIIT3sMainMenuWindow.UIRibMainWindow.UIItemTabPage
Dim uIItemButton As RadButtonTestControl = Me.UIIT3sMainMenuWindow.UIRibMainWindow.UIItemButton
'Click tab
Mouse.Click(uIItemTabPage, New Point(63, 9))
'Click button numbered 6 in 'ribMain' window
Mouse.Click(uIItemButton, New Point(22, 22))
End Sub
<GeneratedCode("Coded UITest Builder", "11.0.60315.1")> _
Partial Public Class UIMap
'''<summary>
'''NewRole - Use 'NewRoleParams' to pass parameters into this method.
'''</summary>
Public Sub NewRole()
Dim uIItemButton As RadButtonTestControl = Me.UIRolesWindow.UIRadRibbonBar1Window.UIItemButton
Dim uIRadGridView1Table2 As RadGridViewTestControl = Me.UIRolesWindow.UIRadGridView1Window.UIRadGridView1Table2
Dim uIRadGridView1Table3 As RadGridViewTestControl = Me.UIRolesWindow.UIRadGridView1Window.UIRadGridView1Table3
Dim uIItemEdit As WinEdit = Me.UIRolesWindow.UIRadGridView1Table4.UIItemWindow.UIItemEdit
Dim uIRadGridView1Table4 As RadGridViewTestControl = Me.UIRolesWindow.UIRadGridView1Window.UIRadGridView1Table4
Dim uIItemEdit1 As WinEdit = Me.UIRolesWindow.UIRadGridView1Table5.UIItem0Window.UIItemEdit
Dim uIRadGridView1Table5 As RadGridViewTestControl = Me.UIRolesWindow.UIRadGridView1Window.UIRadGridView1Table5
Dim uIItemButton1 As RadButtonTestControl = Me.UIRolesWindow.UIRadRibbonBar1Window.UIItemButton1
Dim uIYesButton As WinButton = Me.UISaveWindow.UIYesWindow.UIYesButton
'Click button numbered 2 in 'RadRibbonBar1' window
Mouse.Click(uIItemButton, New Point(9, 23))
'Click 'RadGridView1' table
Mouse.Click(uIRadGridView1Table2, New Point(65, 188))
'Click 'RadGridView1' table
Mouse.Click(uIRadGridView1Table3, New Point(68, 181))
'Type 'Admin' in text box
uIItemEdit.Text = Me.NewRoleParams.UIItemEditText
'Click 'RadGridView1' table
Mouse.Click(uIRadGridView1Table4, New Point(183, 178))
'Type '0' in text box
uIItemEdit1.Text = Me.NewRoleParams.UIItemEditText1
'Click 'RadGridView1' table
Mouse.Click(uIRadGridView1Table5, New Point(248, 308))
'Click button numbered 5 in 'RadRibbonBar1' window
Mouse.Click(uIItemButton1, New Point(8, 17))
'Click '&Yes' button
Mouse.Click(uIYesButton, New Point(43, 13))
End Sub