Test Automation with the New menuStrip Control

I’ve run into an interesting technical roadblock. A core test automation technique is automated UI testing for Windows form-based applications, where the test automation manipulates a "regular" program through the program’s user interface. There are several ways to do this but my preferred way is to make Win32 API function calls (such as to the SendMessage() function) using C# with the P/Invoke mechanism. Test automation scenarios using this technique often contain code which accesses the Main Menu (File, Edit, View, etc.) of application under test. There is a special set of Win32 API functions which manipulate an application’s Menu: GetMenu(), GetSubMenu(), and GetMenuItemID(). So far, so good, for test automation to manipulate a MainMenu on most Windows form-based applications. But the .NET Framework versions 2.0 and 3.0 have a new way for application developers to create a Menu. The new control is called the menuStrip control and you can think of it is an optional upgrade to the older MainMenu control. The menuStrip control looks nicer, has additional features, and is more consistent with other control models than the older MainMenu control. However, in some preliminary test automation experiments on applications which use the new menuStrip control, I have been completely unable to access and manipulate the menuStrip control using existing Win32 API functions, or find any new Win32 API functions which work with the menuStrip control. Perhaps it’s just not possible to automate a menuStrip using Win32, and I’ll have to rely on built-in .NET methods and properties of the menuStrip control. I’ll write up the solution to this technical roadblock when I figure it out.
Advertisements
This entry was posted in Software Test Automation. Bookmark the permalink.