使用带有MessageBoxButtons.YesNoCancel的MessageBox进行自动测试

时间:2013-05-13 08:29:39

标签: c# winforms automated-tests messagebox white

我正在使用TestStack.White框架进行WinForms .Net 2.0 C#应用程序的编码自动回归测试。处理确定/取消消息框(MessageBox.Show(...))没有问题,但在使用MessageBoxButtons.YesNoCancel时我无法处理是/否按钮。事实是,我不知道按钮名称是什么。

这些在我的测试夹具中起作用:

    public ButtonTestJig OkButton
    {
        get { return new ButtonTestJig(Window, "okButton"); }
    }

    public ButtonTestJig CancelButton
    {
        get { return new ButtonTestJig(Window, "cancelButton"); }
    }

是否有人知道NO按钮的等效“cancelButton”和YES按钮的等效“okButton”?或者甚至更好,如何找到它们。我的谷歌搜索失败了。

由于

1 个答案:

答案 0 :(得分:1)

您可以使用http://uiautomationverify.codeplex.com/releases/view/11366或inspect.exe(Windows SDK中的内容,查看这些控件的自动化ID是什么。