【问题标题】:How to access a child window inside a main window in White Framework如何在 White Framework 的主窗口中访问子窗口
【发布时间】:2016-09-22 15:41:47
【问题描述】:

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

以下是参考代码:

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();
    }

【问题讨论】:

    标签: c# windows ui-automation white-framework


    【解决方案1】:

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

    AutomationElement rootElement = AutomationElement.RootElement;
        var winCollection = rootElement.FindAll(TreeScope.Children, Condition.TrueCondition);
    
        foreach (AutomationElement element in winCollection)
            Console.WriteLine(element.Current.Name);
    

    【讨论】:

      猜你喜欢
      • 2016-02-05
      • 1970-01-01
      • 2018-07-15
      • 2021-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多