This project is read-only.

Attempting to access Items/ItemsAsList/ItemsAsCUITe results in NotSupportedException on CUITe_WinList

Jul 25, 2014 at 8:32 PM
Edited Jul 25, 2014 at 8:46 PM
When I try to access items on a WinList, regardless of type, it throws a NotSupportedException stating that the underlying control is of type Window. I'm a bit new to Coded UI so I may be doing something incorrectly.

Object model:
public class FileExplorer : CUITe_WinClient
     private CUITe_WinWindow _fileListWindow;
     private CUITe_WinList _filesList;

     public FileExplorer() : base("ClassName=CabinetWClass") { }
     public FileExplorer(string path) :
           base("ClassName=CabinetWClass") { path.Run();}
    private CUITe_WinWindow FilesWindow { get { return _fileListWindow ?? 
            (_fileListWindow = 
             Get<CUITe_WinWindow>("AccessibleName=Items View")); } }

     public CUITe_WinList FilesList { get { return _filesList ?? 
            (_filesList = 
             FilesWindow.Get<CUITe_WinList>("ClassName=DirectUIHWND")); } }
CodedUITest using the class
public void CodedUITestMethod1()
     var fileExplorer = new FileExplorer(@"C:\Users\");
     var item = fileExplorer.FilesList.ItemsAsCUITe[0];
     //other stuff
Error and stacktrace
Test Name:  CodedUITestMethod1
Test FullName:  CUITe_Test.CodedUITest1.CodedUITestMethod1
Test Source:    *Omitted*
Test Outcome:   Failed
Test Duration:  0:00:09.7191603

Result Message: 
Test method CUITe_Test.CodedUITest1.CodedUITestMethod1 threw exception: 
System.NotSupportedException: GetProperty of "Items" is not supported on control type: Window
Result StackTrace:  
at Microsoft.VisualStudio.TestTools.UITesting.UITestPropertyProvider.MapAndThrowException(Exception exception)
   at Microsoft.VisualStudio.TestTools.UITesting.UITestPropertyProvider.GetPropertyValueWrapper(UITestControl uiControl, String propertyName)
   at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyValuePrivate(String propertyName)
   at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetPropertyPrivate(String propertyName)
   at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<>c__DisplayClass3b.<GetProperty>b__3a()
   at Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
   at Microsoft.VisualStudio.TestTools.UITesting.UITestControl.GetProperty(String propertyName)
   at Microsoft.VisualStudio.TestTools.UITesting.WinControls.WinList.get_Items()
   at CUITe.Controls.WinControls.CUITe_WinList.get_ItemsAsCUITe() in *directory*\CUITe\Controls\WinControls\CUITe_WinList.cs:line 78
   at CUITe_Test.CodedUITest1.CodedUITestMethod1() in *directory*\CUITe_Test\CodedUITest1.cs:line 26
Any ideas on what I may be doing wrong or what is causing this?

I found a similar thread here: mentioning class name being funky in the search properties, however I didn't see a resolution. Thanks.
Jul 25, 2014 at 8:55 PM
Appears this was due to class name. Using a different control search property (Name=Items View) returns the correct control.