This project is read-only.

CustomUIItem issue with Pane/Panel controls

Oct 15, 2008 at 5:41 PM

I'm trying to automation my AUT by using the CustomUIItem approach for a control based on a Pane, I couldnt get it to work so I tried the same on your WinFormsTestApp applicaton.

In the following code the first line of the test throws an exception (System.InvalidCastException : Unable to cast object of type 'PropertyGridProxy36e0add6f7a4459bb4b05a97bc078579' to type 'Core.UIItems.MyPanelUIItem'.), what am I missing?




public void FindCustomItem()
        MyPanelUIItem myPanelUIItem = window.Get<MyPanelUIItem>("panelWithText");
        Assert.AreNotEqual(null, myPanelUIItem);



public class MyPanelUIItem : CustomUIItem
        public MyPanelUIItem(AutomationElement automationElement, ActionListener actionListener) : base(automationElement, actionListener) { }
        protected MyPanelUIItem() { }


Oct 18, 2008 at 9:06 AM
This is a bug, I am looking into it. I would update you when I find the fix.
Oct 20, 2008 at 10:13 AM
This is a bug which shows up in case of CustomUIItem and when Position based search is used for performance. i.e. when you use identification for window. (

I have fixed the issue, would be available in next release.

For your immediate need:
1. Do not use position based search i.e. don't use identification for windows
2. public virtual IUIItem Get(ContainerItemFactory containerItemFactory, SearchCriteria searchCriteria, ActionListener actionListener)
            Point location = windowItemsMap.GetItemLocation(searchCriteria);
            WhiteLogger.Instance.Debug("Finding UIItem based on criteria: " + searchCriteria);
            if (location.Equals(C.UnlikelyWindowPosition))
                WhiteLogger.Instance.Debug("Could not find based on position, finding using search");
                return Create(containerItemFactory, searchCriteria, actionListener);
            AutomationElement automationElement = AutomationElement.FromPoint(location);
            WhiteLogger.Instance.Debug("Found UIItem based on position");
            if (searchCriteria.AppliesTo(automationElement))
                IUIItem item = new DictionaryMappedItemFactory().Create(automationElement, actionListener, searchCriteria.CustomItemType);
                return (IUIItem) DynamicProxyGenerator.Instance.CreateProxy(new CoreInterceptor(item, actionListener), item.GetType());

            WhiteLogger.Instance.Debug("UIItem changed its position, find using search");
            return Create(containerItemFactory, searchCriteria, actionListener);

Change italicized line as indicated
Oct 20, 2008 at 10:18 AM
Thanks for the quick reponse, as always.

Jun 26, 2009 at 9:05 PM

where can I find this WinFormsTestApp applicaton? or where can I find some sample code?