简体   繁体   中英

Coded UI Test: The test run will not open a simple menu

I am being asked to evaluate Visual Studio for our automation testing efforts. I have chosen to create a simple Coded UI Test where I simply want to open up Minesweeper (Win7 version), play with the custom game options and then close the application.

Every time I Run the test, it will not open the 'Game' menu item.

// Click 'Game' -> 'Options F5' menu item
Mouse.Click(uIOptionsF5MenuItem, new Point(26, 6));

Now, if I myself click the menu item (basically giving the test a 'push'), the automation takes over by selecting the menu option I need and then will run without any issue. I just can't figure out why the test can not open this menu on its own. I've tried the SetFocus method already and I haven't found any other options. The MSDN documentation offers ZERO help.

Anyone have an idea how I can get this menu to open?

Result Message: 
Test method Blorg.CodedUITest1.CodedUITestMethod1 threw exception: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details: 
TechnologyName:  'MSAA'
ControlType:  'MenuItem'
Name:  'Options F5'

Try adding the menu item and perform the click like this,

WinMenuItem uIOptionsF5MenuItem = new WinMenuItem(Add the window where the menu is placed) {TechnologyName="MSAA" };
uIOptionsF5MenuItem.SearchProperties.Add("Name", "Options F5");
Mouse.Click(uIOptionsF5MenuItem);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM