Initializing CustomUIItem Variables in the Constructor

Oct 22, 2010 at 9:18 PM

I have a set of 3 CustomUIItems in a class. Two of them contain the third CustomUIItem in their structure. What I am trying to do is initialize the third CustomUIItem in each of the other two's constructor. So that the methods don't each have to find the CustomUIItem, it can be found in the constructor once, then used throughout. When I try doing this I get a  White.Core.WhiteException:. It is blank, but it happens on the line in the constructor. Here is some sample code:

 

[ControlTypeMapping(CustomUIItemType.Custom)]
    public class ChannelGang : CustomUIItem
    {

        private TransportControls transportControls;

        public ChannelGang(AutomationElement automationElement, ActionListener actionListener)
            : base(automationElement, actionListener)
        {
            transportControls = Container.Get<TransportControls>("transportControls");
        }

        protected ChannelGang() { }
      

        public void Play()
        {
            transportControls.Play();
        }

}

 [ControlTypeMapping(CustomUIItemType.Custom)]
    public class TransportControls : CustomUIItem
    {

          ..............

 

Right now I have to do this:

[ControlTypeMapping(CustomUIItemType.Custom)]
    public class ChannelGang : CustomUIItem
    {

        private TransportControls transportControls;

        public ChannelGang(AutomationElement automationElement, ActionListener actionListener)
            : base(automationElement, actionListener)
        {
        }

        protected ChannelGang() { }
      

        public void Play()
        {
           transportControls = Container.Get<TransportControls>("transportControls");
           transportControls.Play();
        }

}

Coordinator
Nov 21, 2010 at 5:48 AM

can you also post the exception that you are getting along with stack trace

Nov 22, 2010 at 6:23 PM

The error is blank. This is what it is:

 White.Core.WhiteException:

Here is the error stack trace:

AtlasAutomationFramework.ChannelViewer..ctor(AutomationElement automationElement, ActionListener actionListener) in M:\*_*\*_*\*\*\*\AtlasChannelPanel.cs: line 34  (this is the line grabbing transport controls)
System.RuntimeMethodHandle._InvokeConstructor(Object[] args, SignatureStruct& signature, IntPtr declaringType)
System.RuntimeMethodHandle.InvokeConstructor(Object[] args, SignatureStruct signature, RuntimeTypeHandle declaringType)
System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
System.Reflection.ConstructorInfo.Invoke(Object[] parameters)
Bricks.RuntimeFramework.Class.New(Object[] arguments)
White.Core.Factory.DictionaryMappedItemFactory.Create(AutomationElement automationElement, Type itemType, ActionListener actionListener)
White.Core.Factory.DictionaryMappedItemFactory.Create(AutomationElement automationElement, ActionListener actionListener, Type customItemType)
White.Core.Factory.PrimaryUIItemFactory.Create(SearchCriteria searchCriteria, ActionListener actionListener)
White.Core.UIItems.Container.NonCachedContainerItemFactory.Find(SearchCriteria searchCriteria)
White.Core.UIItems.Container.ContainerItemFactory.Get(SearchCriteria searchCriteria, ActionListener uiItemActionListener)
White.Core.Sessions.NullWindowSession.Get(ContainerItemFactory containerItemFactory, SearchCriteria searchCriteria, ActionListener actionListener)
White.Core.UIItems.Container.CurrentContainerItemFactory.Find(SearchCriteria searchCriteria, WindowSession windowSession)
White.Core.UIItems.UIItemContainer.Get(SearchCriteria searchCriteria)
White.Core.UIItems.UIItemContainer.Get(SearchCriteria searchCriteria)
White.Core.UIItems.UIItemContainer.Get[T](SearchCriteria searchCriteria)
White.Core.UIItems.UIItemContainer.Get[T](String primaryIdentification)
AtlasAutomationFramework.ChannelPanel.GetChannelViewers() in M:\*_*\*_*\*\*\*\AtlasChannelPanel.cs: line 1372
AtlasAutomationFramework.ChannelPanel..ctor(AtlasApplication parent, String panelId) in M:\***_*\*_*\*\*\*\AtlasChannelPanel.cs: line 1252
AtlasAutomatedTest.AtlasAutomatedTests.MyTest() in M:\***_*\*_*\*\*\*\AtlasAutomatedTests.cs: line 244

 

Should this code work? Is it possible to grab things like that (or do call other methods) when the custom UI item is created?

Coordinator
Nov 23, 2010 at 1:56 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.