Cann't get the MenuItem

Jun 18, 2009 at 5:51 PM

Hi All-

I am trying to use White for automating a WPF application, but the following code fails with exception: "Error Invoking MenuBar.MenuItem" with inner exception of "Could not find Menu Name=Exit". However looking at the app in UISpy, I can definitely see the MenuItem "Exit" under "File" menu item. Any ideas of what I might be doing wrong. 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<font size="2">

 

</font>

 

public void

TestMethod1(){<font size="2">

 

</font>

 

// Start the app

try

{

<font size="2">

 

</font>

 

Application application = Application.Attach(5160);<font size="2">

 

</font>

 

Assert.IsNotNull(application);<font size="2">

 

</font>

 

// Find the main window

<font size="2">

 

</font>

 

SearchCriteria sc = SearchCriteria.ByAutomationId("mainWindow");<font size="2">

 

</font>

 

Window mainWin = application.GetWindow("Download Management Studio - BVT", Core.Factory.InitializeOption.NoCache);<font size="2">

 

</font>

 

Assert.IsNotNull(mainWin);<font size="2">

Core.UIItems.WindowStripControls.

</font>

MenuBar

mainMenu = mainWin.MenuBar;<font size="2">

 

</font>

 

Menu exit = mainMenu.MenuItem("File", "Exit");<font size="2">

exit.Click();

</font>

 

 

}

<font size="2">

 

</font>

 

catch (Exception ex)

{

<font size="2">

 

</font>

 

Console.Write(ex.Message);

}

Coordinator
Jun 25, 2009 at 3:23 PM

May be number 3 here. http://white.codeplex.com/Wiki/View.aspx?title=Other%20questions