Unable to Click the Menu Item for the second time

Mar 24, 2012 at 11:13 PM

Hi, 

I am new to this framework. 

I am have an application (AAA.exe) where I have Clicked on MenuBar > MenuItem, Which Invokes another application (BBB.exe) [separate processs]
When I am trying to Click the menu Item for the second time getting the following error.  

 

static void Main(string[] args)
        {
           string MAIN_WIN_TITLE = "AAA";
           Window mainWindow = FindByWindowTitle(QB_MAIM_WIN_TITLE);
           mainWindow.WaitWhileBusy();
           mainWindow.Focus(0);
           
           var menuBar = mainWindow.MenuBar;
           Menu InvokeSetUpSyncManager = menuBar.MenuItem("Services", "Set Up Sync Manager");
           InvokeSetUpSyncManager.Click();
           System.Threading.Thread.Sleep(15000);
          
	  // BBB.EXE is opened  -   workings fine         
           Window SyncSetUpWin = FindByWindowTitle("Sync Manager"); 
            
          //SET THE MAIN APP (AAA.EXE) FOR FOCUS 
	   mainWindow.Focus(0);

             

Console.WriteLine(InvokeSetUpSyncManager.GetType()); //returns White.Core.UIItems.MenuItems.Menu

InvokeSetUpSyncManager.Click(); //Failed to click }

 

Message:
The target element corresponds to UI that is no longer available (for example, the parent window has closed).   
at MS.Internal.AutomationProxies.Misc.ThrowWin32ExceptionsIfError(Int32 errorCode)   
at MS.Internal.AutomationProxies.Misc.GetMenuItemRect(IntPtr hwnd, IntPtr hmenu, Int32 item, Win32Rect& rc)   
at MS.Internal.AutomationProxies.WindowsMenu.MenuItem.get_BoundingRectangle()   
at MS.Internal.AutomationProxies.ProxySimple.System.Windows.Automation.Provider.IRawElementProviderFragment.get_BoundingRectangle()


Stack Trace:

at MS.Internal.Automation.UiaCoreApi.CheckError(Int32 hr)   
at System.Windows.Automation.AutomationElement.GetCurrentPropertyValue(AutomationProperty property, Boolean ignoreDefaultValue)   
at System.Windows.Automation.AutomationElement.GetPatternPropertyValue(AutomationProperty property, Boolean useCache)   
at System.Windows.Automation.AutomationElement.AutomationElementInformation.get_BoundingRectangle()   
at White.Core.UIItems.UIItem.get_Bounds() in c:\white\Components\Core\Source\UIItems\UIItem.cs:line 85   
at White.Core.UIItems.UIItem.PerformClick() in c:\white\Components\Core\Source\UIItems\UIItem.cs:line 222   
at White.Core.UIItems.UIItem.Click() in c:\white\Components\Core\Source\UIItems\UIItem.cs:line 216   
at QBTest.Program.Main(String[] args) in c:\users\ABCD\documents\visual studio 2010\Projects\FirstTest\FirstTest\Program.cs:line 56