Custom Item?

Dec 15, 2009 at 2:14 PM



There is a Custom ControlType in our product


UIItem item = (UIItem_indow.Get(SearchCriteria.ByAutomationId("sideBar"));


works fine (the ControlType is Custom)

If I try to cast the element to a seldefined CustomControl  I get the following error

=> Unable to cast object of type 'TableHeaderProxya0364d19e8c74536b32eacae16dab34c' to type 'MyCustomUIItems.MySideBar'


ansy idea?


Dec 15, 2009 at 9:40 PM

can you post the code for custom ui item you have written, and how you are searching for it.

Dec 16, 2009 at 8:15 AM

=> the way I search

System.Collections.Generic; using System.Windows.Automation; using SystemTest.CustomUIItems; using White.Core.UIItems; using White.Core.UIItems.Finders; using White.Core.UIItems.WindowItems; using White.Core.UIItems.WPFUIItems; namespace SystemTest.Helper { internal class SideBarHelper { private UIItem _sideBar; private Window _window; /// <summary> /// /// </summary> internal enum SideBarTabType { /// <summary> /// /// </summary> Properties = 0, } /// <summary> /// Initializes a new instance of the <see cref="SideBarHelper"/> class. /// </summary> internal SideBarHelper() { _window = TestSharedFunctions.Window; _sideBar = (UIItem)_window.Get(SearchCriteria.ByAutomationId("sideBar")); }

replacing the Type of _sideBar to MySideBar shows the described error in the first Post


Here the claas for MySideBar


using System.Windows.Automation;
using White.Core.UIItems.Actions;
using White.Core.UIItems.Custom;

namespace SystemTest.CustomUIItems
  public classMySideBar : CustomUIItem
    // Implement these two constructors. The order of parameters should be same.
    public MySideBar(AutomationElement automationElement, ActionListener actionListener)
      : base(automationElement, actionListener)

    //Empty constructor is mandatory with protected or public access modifier.
    protected MySideBar() { }


If I  understand right I can also use Get and GetMultiple on Custom UIItems?


in the moment I try to use IUIItem[] items = _sideBar.GetMultiple(SearchCriteria.All);


but I get a NullReferenceException


using AutomationElements to find something works fine

Dec 18, 2009 at 2:18 PM

I have found a way to get the SideBar as MySideBar:


AutomationElement element = window.AutomationElement.FindFirst( TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "sideBar" ));
if(element != null)
_sideBar = new MySideBar( element, _ets4Window.ActionListener );

if I implement in each custom control something like that to get Buttons and so on it works fine :)

but I think this is not the way White want to do such things, right?

Dec 20, 2009 at 12:43 PM

GetMultiple is not working for CustomUIItem. I have created an issue which should get fixed in the next release.

Dec 21, 2009 at 2:03 PM

ah ok


is there a difference between "Get" on CustomUIItem  or "normal" UIItems?


it seems that the Get on UIItems search with TreeScope.Descendandents and on CustomUIItems with TreeScope.Children

May 23, 2010 at 10:43 PM


Jun 3, 2010 at 7:21 AM

Can you point of which methods you are pointing to as I don't any Get method on UIItem or CustomUIItem.