如何在 White Framework 中访问主 window 中的子 window

How to access a child window inside a main window in White Framework

我正在使用 White 框架在 Windows 基于桌面的应用程序中执行 UI 自动化。我找不到访问子项的方法 window。 UIAVerify 将 window 的属性描述为:

以下代码供参考:

public class Program
{
    Application app = Application.Launch("Path to my application");

    public Program()
    {
        //Getting the main window
        Window MainWindow = app.GetWindow("MainForm", InitializeOption.NoCache);
        MainWindow.WaitWhileBusy();
        **//Here I wanna get the child window so that I can access controls on that window. Below is the code for getting child windows controls** 
        //Getting to the Firm box
        TextBox firm = Childwindow.Get<TextBox>(SearchCriteria.ByAutomationId("1313948"));
        //setting value for firm
        firm.SetValue("FIRM2");
        //getting StaffID text box
        TextBox StaffID = Childwindow.Get<TextBox>(SearchCriteria.ByAutomationId("723272"));
        StaffID.SetValue("Staff");

        Button Ok = Childwindow.Get <Button>(SearchCriteria.ByAutomationId("_okB[enter image description here][1]utton"));
        Ok.Click();
    }

使用TreeScope.Children访问桌面的直接子元素:

AutomationElement rootElement = AutomationElement.RootElement;
    var winCollection = rootElement.FindAll(TreeScope.Children, Condition.TrueCondition);

    foreach (AutomationElement element in winCollection)
        Console.WriteLine(element.Current.Name);