This is a migrated thread and some comments may be shown as answers.

CodedUITest fails on Telerik grid

5 Answers 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Celeste Zietsman
Top achievements
Rank 2
Celeste Zietsman asked on 18 Jul 2013, 02:04 PM

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

5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 23 Jul 2013, 11:12 AM
Hello Celeste,

Thank you for writing.

You should set RadGridView EnableCodedUITest property to true in order to enable CodedUI Tests functionality. This property triggers the support for Visual Studio Automated Tests and turns off the support for Windows Narrator.
radGridView1.EnableCodedUITests = true

I hope this helps.

Regards,
Peter
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Celeste Zietsman
Top achievements
Rank 2
answered on 23 Jul 2013, 02:25 PM
Hi Peter

This property is already set to true.

I attached an image of the search criteria it uses and noticed that the Technology Name EqualsTo TPF and it fails on Technology Name: MSAA. Could this be the issue?

Regards
Celeste
0
Peter
Telerik team
answered on 26 Jul 2013, 04:48 AM
Hello Celeste,

Thank you for writing back.

We do not set the TechnologyName. We set the Name property which should be enough to determine the grid control. For example in code this looks like this: 
this.SearchProperties[RadGridViewTestControl.PropertyNames.Name] = "Telerik.WinControls.UI.RadGridView ; 6;9";
 this.SearchProperties["AccessibleDescription"] = null;
 this.SearchConfigurations.Add(SearchConfiguration.VisibleOnly);
 this.WindowTitles.Add("RadControls for Winforms Sampe application");

I would like to suggest to auto generate a codedUI test through the Visual Studio Spy and see which properties are serialized in UIMap.Designer.cs file.

I hope this helps.
 
Regards,
Peter
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Celeste Zietsman
Top achievements
Rank 2
answered on 02 Aug 2013, 09:01 AM
Hi Peter

Could you please point me to any resources that shows how to use the Visual Studio Spy.

Thank You

Regards
Celeste
0
Peter
Telerik team
answered on 06 Aug 2013, 11:21 AM
Hello Celeste,

Thank you for writing back.

I would like to recommend this MSDN article: 
http://msdn.microsoft.com/en-us/library/dd286726.aspx which cover all aspects of the test recording.

I hope this helps.

Regards,
Peter
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Celeste Zietsman
Top achievements
Rank 2
Answers by
Peter
Telerik team
Celeste Zietsman
Top achievements
Rank 2
Share this question
or