How to get controls in nested customUI control?

Jul 15, 2009 at 4:28 PM

I have a hard time to get tab control in a nested  custom UI control, here is the log structure, thank you very much if someone can help me:

 

    AutomationId: m_toolStripContainer_Form
    ControlType: ControlType.Pane
    Name: toolStripContainer1
    HelpText:
    Bounding rectangle: -1210,559,350,336
    ClassName: WindowsForms10.Window.8.app.0.378734a
    IsOffScreen: False

        AutomationId: 1320136
        ControlType: ControlType.Pane
        Name:
        HelpText:
        Bounding rectangle: -1210,584,350,311
        ClassName: WindowsForms10.Window.8.app.0.378734a
        IsOffScreen: False

            AutomationId: m_tabControl_Indi
            ControlType: ControlType.Tab
            Name:
            HelpText:
            Bounding rectangle: -1210,584,350,311
            ClassName: WindowsForms10.SysTabControl32.app.0.378734a
            IsOffScreen: False

                AutomationId:
                ControlType: ControlType.TabItem
                Name: Individual
                HelpText:
                Bounding rectangle: -1208,586,57,18
                ClassName:
                IsOffScreen: False

                    AutomationId: m_toolStripContainer_IndiTab
                    ControlType: ControlType.Pane
                    Name: toolStripContainer1
                    HelpText:
                    Bounding rectangle: -1203,609,336,279
                    ClassName: WindowsForms10.Window.8.app.0.378734a
                    IsOffScreen: False

                        AutomationId: 1773416
                        ControlType: ControlType.Pane
                        Name:
                        HelpText:
                        Bounding rectangle: -1203,609,336,279
                        ClassName: WindowsForms10.Window.8.app.0.378734a
                        IsOffScreen: False

                            AutomationId: m_UC_IndiDetailsOldNew
                            ControlType: ControlType.Pane
                            Name:
                            HelpText:
                            Bounding rectangle: -1204,608,338,276
                            ClassName: WindowsForms10.Window.8.app.0.378734a
                            IsOffScreen: False

                                AutomationId: m_UC_Sex
                                ControlType: ControlType.Pane
                                Name:
                                HelpText:
                                Bounding rectangle: -1090,640,69,23
                                ClassName: WindowsForms10.Window.8.app.0.378734a
                                IsOffScreen: False

                                    AutomationId: m_toolStrip_Sex
                                    ControlType: ControlType.ToolBar
                                    Name: toolStrip1
                                    HelpText:
                                    Bounding rectangle: -1090,640,72,25
                                    ClassName: WindowsForms10.Window.8.app.0.378734a
                                    IsOffScreen: False

                                        AutomationId:
                                        ControlType: ControlType.Button
                                        Name: Male
                                        HelpText:
                                        Bounding rectangle: -1090,641,23,22
                                        ClassName:
                                        IsOffScreen: False

Coordinator
Jul 16, 2009 at 3:53 AM

can you also post what code you are using.

Jul 16, 2009 at 5:38 PM

Thanks very much for quick reply,

Container1(AutomationID: m_toolStripContainer_Form) contains container2 (AutomationID: 1320136), container2 contains a tab control:

1. Container1 defination:

    [ControlTypeMapping(CustomUIItemType.Pane)]
    public class MyIndiContainer1UIItem : CustomUIItem
    {
        private MyIndiContainer2UIItem container2;
   
        public MyIndiContainer1UIItem(AutomationElement automationElement, ActionListener actionListener)
            : base(automationElement, actionListener)
        {
            container2 = new MyIndiContainer2UIItem(automationElement, actionListener);
        }

     
        protected MyIndiContainer1UIItem() { }

        public virtual MyIndiContainer2UIItem getContainer2
        {
            get { return container2; }
        }
    }

1. Container2 defination:

[ControlTypeMapping(CustomUIItemType.Pane)]
    public class MyIndiContainer2UIItem : CustomUIItem
    {
        private Core.UIItems.TabItems.TabPage inditabs;

        public MyIndiContainer2UIItem(AutomationElement automationElement, ActionListener actionListener)
            : base(automationElement, actionListener)
        {
            inditabs = new Core.UIItems.TabItems.TabPage(automationElement, actionListener);
        }

       
        protected MyIndiContainer2UIItem() { }

        
        public virtual Core.UIItems.TabItems.TabPage getTabItem
        {
            get { return inditabs;}
        }
    }

3. Test code:

        whitetest.MyIndiContainer1UIItem container1 = organizeFamilytreeWindow.Get<whitetest.MyIndiContainer1UIItem>("m_toolStripContainer_Form");
        whitetest.MyIndiContainer2UIItem container2 = container1.getContainer2;

Coordinator
Jul 18, 2009 at 9:26 AM

I am not sure why you are using CustomUIItem for this.

you can directly get hold of the tabcontrol from the window using window.Get<Tab>("m_tabControl_Indi");

In any case......

container2 = new MyIndiContainer2UIItem(automationElement, actionListener);

inditabs = new Core.UIItems.TabItems.TabPage(automationElement, actionListener);

both the above lines are wrong. You are trying to instantiate container2 from container1's AE, and similarly tab from something else's automation element. You would have to put code like:

this.Get<Tab>("m_tabControl_Indi") in the second case for example.

Jul 20, 2009 at 4:39 PM

Thank you very much for quick reply. I did try to get the tab directly, but I made typo mistake at the beginning which made me tried lots of other ways to get hold of the tab. I thought that maybe I need to get hold of the containers which contains tha tab first. Anyway, after I read your reply, I rechecked my code, found the problem and fixed it. thank you very much for pointing me the right way.