Locate custom UIItem in office

Jun 3, 2010 at 9:53 AM

Hi, i am newbie for white. i am trying to locate a logon window which pops up after clicking one of the menu items from our excel add-in. But unfortunately, the window can hardly be located.

my ugly code are:


public void LaunchExcel()
            string path = "C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE";
            Application application = Application.Launch(path);
            Window window = application.GetWindow("Microsoft Excel - Book1", InitializeOption.NoCache);

            Panel panel = window.Get<Panel>(SearchCriteria.ByNativeProperty(AutomationElementIdentifiers.ClassNameProperty, "EXCEL2"));

            MenuBar bar = panel.Get<MenuBar>(SearchCriteria.ByText("Worksheet Menu Bar"));
            Menu logon = bar.MenuItem("QA XL", "Logon");

            bar.MenuItemBy(SearchCriteria.ByText("QA XL"), SearchCriteria.ByText("Logon")).Click();

            Window logonWin1 = application.GetWindow("QA", InitializeOption.NoCache);


But the logonWin1 always returns null when debug...

the window properties displays in UISpy are:

ClassName: "ThunderRT6FormDC"    

ControlType: "ControlType.Window"  

Culture: "(null)"    AutomationId: ""    

LocalizedControlType: "window"    

Name: "QA"


now my workaround is (replace the last statement):

            List<Window> windows = application.GetWindows();

            Window logonwin5 = windows[windows.Count - 1];

Do anybody have idea how to handle this?




Jun 3, 2010 at 6:59 PM
Hi I my opinion, the best method to get Windows of the application is this: application.GetWindows().Where(p=>p.Name =="Name").First(); the GetWindow() method is disaffected if you not search the MainWindow. (only my experiance) Throndorin