如何访问白色的消息框?
我在 WPF 应用程序中有一个简单的消息框,启动如下:
private void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Howdy", "Howdy");
}
我可以获得 white< /a> 单击我的按钮并启动消息框。
UISpy 将其显示为我的窗口的子窗口,我无法找出访问它的方法。
如何访问我的 MessageBox 以验证其内容?
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 shows it as a child of my window I couldn't work out the method to access it.
How do I get access to my MessageBox to verify its contents?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
window.MessageBox() 是一个很好的解决方案!
但如果消息框不出现,此方法会卡住很长时间。 有时我想检查消息框的“未出现”(警告、错误等)。 所以我写了一个方法通过线程来设置timeOut。
window.MessageBox() is a good solution!!
But this method would stuck for a long time if the messagebox doesn't appear. Sometimes I want to check "Not Appearance" of a messagebox (Warning, Error, etc.). So I write a method to set the timeOut by threading.
White 源代码中包含一些 UI 测试项目(用于测试 White 本身)。
其中一个测试包括 MessageBox 测试,其中包括一种获取显示消息的方法。
显然,用于显示文本消息的标签属于显示消息框的窗口,其主要标识是最大字值(65535)。
Contained in the White source code are some UI tests projects (to test White itself).
One of the test includes MessageBox tests, which includes a way to obtain the displayed message.
Evidently, the label used to display the text message is owned by the window displaying the messagebox, and its primary identification is the max word value (65535).
找到了! 窗口类有一个 MessageBox 方法可以做到这一点:
Found it! The window class has a MessageBox method that does the trick:
请尝试这个
Please try this