Track WPF message box text and confirmation box &#

2019-06-08 15:44发布

问题:

How can we track the message from the WPF message box instead of web, also how to click 'Yes' button of a confirmation message box in Coded UI Testing programmatically?

I tried the following but it's not working:

for message box:

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

for confirmation dialogue 'Yes' button:

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

Thanks for the help!!!

回答1:

Use "record" facility to get all the details:

Record actions

Thanks!