本文介绍了如何访问带有白色的MessageBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在WPF应用程序中有一个简单的消息框,如下所示:
I have a simple message box in a WPF application that is launched as below:
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Howdy", "Howdy");
}
我可以让白色单击我的按钮并启动消息框.
I can get white to click my button and launch the message box.
UISpy将其显示为我的窗口的子级,我无法确定访问它的方法.
UISpy shows it as a child of my window I couldn't work out the method to access it.
如何访问我的MessageBox以验证其内容?
How do I get access to my MessageBox to verify its contents?
推荐答案
找到了!窗口类具有一个可完成此操作的MessageBox方法:
Found it! The window class has a MessageBox method that does the trick:
var app = Application.Launch(@"c:\ApplicationPath.exe");
var window = app.GetWindow("Window1");
var helloButton = window.Get<Button>("Hello");
Assert.IsNotNull(helloButton);
helloButton.Click();
var messageBox = window.MessageBox("Howdy");
Assert.IsNotNull(messageBox);
这篇关于如何访问带有白色的MessageBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!