<p>I have a simple message box in a WPF application that is launched as below:</p>

<pre><code>private void Button_Click(object sender, RoutedEventArgs e)
{
   MessageBox.Show("Howdy", "Howdy");
}
</code></pre>

<p>I can get <a href="http://www.codeplex.com/white" rel="nofollow noreferrer" title="white">white</a> to click my button and launch the message box.  </p>

<p>UISpy shows it as a child of my window I couldn't work out the method to access it.</p>

<p>How do I get access to my MessageBox to verify its contents?</p>

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