Search code examples
c#.netwinformsuser-interfacetesting

Programatically finding a message box and generating a click on a button


I am trying to automate testing of a winform application. I am running it in the same process as the test code, so it is fairly easy to find the .Net controls and simulate user action on them. I got however stuck a bit with a message box (created using the standard MessageBox.Show method). How can I get hold of it and simulate that a button is pressed?


Solution

  • You probably will have to use WinAPI calls (FindWindowEx, ect) and send a messages of LMB down and up to a button handle.