在编码 UI 测试中跟踪 WPF 消息框文本和确认框 'Yes' 按钮

Track WPF message box text and confirmation box 'Yes' button in Coded UI testing

我们如何跟踪来自 WPF 消息框而不是 Web 的消息,以及如何在 Coded UI 测试中以编程方式单击确认消息框的 'Yes' 按钮?

我尝试了以下方法,但没有用:

对于消息框:

    UITestControl msgBox = new UITestControl(App);
    msgBox.TechnologyName = "MSAA";
    msgBox.SearchProperties.Add("ControlType", "Text");
    msgBox.SearchProperties.Add("Name", "Test cases added successfully.");
    bool isExist = msgBox.Exists;
    Assert.IsTrue(isExist);

用于确认对话 'Yes' 按钮:

    UITestControl btnYes = new UITestControl(App);
    btnYes.TechnologyName = "MSAA";
    btnYes.SearchProperties.Add("ControlType", "Button");
    btnYes.SearchProperties.Add("AutomationId", "Yes");
    Mouse.Click(btnYes);

感谢帮助!!!

使用“记录”工具获取所有详细信息:

Record actions

谢谢!