Window with Same Name

Mar 26, 2010 at 1:52 PM
Edited Mar 26, 2010 at 3:03 PM

Hallo,

Window A und Window B have the same name, Window B is a dialog window of Window A.  Window B is called by clicking a button "Button1"

in Window A. I have found two Windows correctly, when jumping the exception of clicking Button1 up.

But by clicking "Button1",   the exception  "BricksException was unhandled, Error invoking Button.Click" throws out,

and Window B displays at the same time. 

This is the logStructure():


 AutomationId: 9496
 ControlType: ControlType.Button
 Name: Suchen
 HelpText:
 Bounding rectangle: 403;556;51;21
 ClassName: Button
 IsOffScreen: False
 FrameworkId: Win32
 ProcessId: 2276

 System.Windows.Automation.InvokePattern

 AutomationId: 9497
 ControlType: ControlType.Button
 Name: Rücksetzen
 HelpText:
 Bounding rectangle: 458;556;71;21
 ClassName: Button
 IsOffScreen: False
 FrameworkId: Win32
 ProcessId: 2276

 System.Windows.Automation.InvokePattern

 AutomationId: 9498
 ControlType: ControlType.Button
 Name: Abbrechen
 HelpText:
 Bounding rectangle: 533;556;60;21
 ClassName: Button
 IsOffScreen: False
 FrameworkId: Win32
 ProcessId: 2276

 System.Windows.Automation.InvokePattern

Only the Button "Suchen" has the exception, other three work very well.

What may the problem be? Is there something with process to do?

Thanks.

 

Mar 26, 2010 at 5:26 PM

Is it possible for you to paste the code for AUT. So that I can try it out at my end. Did you try using index?

Also refer this URL and see if you can find some code  sample that addresses your issue.  http://white.codeplex.com/wikipage?title=UIItem%20Identification&referringTitle=Home

Mar 29, 2010 at 7:42 AM
Edited Mar 29, 2010 at 7:55 AM

Thanks for your answers.

This is my helper function.

   public Window FindOnlyDialogWindowWithSameName(string winName)
        {
            Window tmpWin = null;
        
            List<Window> SameWindows=new List<Window>();
            
            windows = Desktop.Instance.Windows();
     
        
            for (int i = 0; i < windows.Count; i++)
            {
                if (windows[i].Name.Equals(winName))
                {
                                      WindowPattern wnd = windows[i].AutomationElement.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern;

                    if (wnd.Current.WindowInteractionState == WindowInteractionState.ReadyForUserInteraction)
                         tmpWin =windows[i];


                }
            }

                      
                      
            return tmpWin;
        }
Then in my test function: 

 

            Window windowA= helper.FindOnlyDialogWindowWithSameName(NameString);
            helper.CheckButtonEnableStatusWithName(windowA, buttons, new bool[] {true ,true ,true ,true  });
               
            Button Suchen=windowA.Get<Button>("Suchen");
            Suchen.Click();  
 
            Window windowB=helper.FindOnlyDialogWindowWithSameName (NameString);
                     
            Button Ja=windowB.Get<Button>("Ja");
            Ja.Click();
I have checked button status. There is no problem to find the button "Suchen".
Only by clicking it, the exception is thrown out.
Mar 29, 2010 at 8:09 AM

Assuming that you are trying to access a modal form opened from within a parent form, I have tweaked your function as given below.  I have added an additional parameter where i pass the ref of parent form and then use teh modal window property to access the modal form.

Hope this helps

 

 public Window FindOnlyDialogWindowWithSameName(string winName,Window parentWindow)
        {
            Window tmpWin = null;

            List<Window> SameWindows = new List<Window>();

            //SameWindows = Desktop.Instance.Windows();
            SameWindows = parentWindow.ModalWindows();
            
            for (int i = 0; i < SameWindows.Count; i++)
            {
                if (SameWindows[i].Name.Equals(winName))
                {
                    WindowPattern wnd = SameWindows[i].AutomationElement.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern;

                    if (wnd.Current.WindowInteractionState == WindowInteractionState.ReadyForUserInteraction)
                        tmpWin = SameWindows[i];


                }
            }



            return tmpWin;
        }
Mar 29, 2010 at 8:32 AM

Thanks deepban74. I have tried your code.

 The windowA is null.  This is not a modal window, only the nomal window.

  By logstruture(), there is no problem to find the window and button. Only by clicking button, exception

  occurs. After the first time of the exception, I have written another test case, when the two case run sequently.

 The exception doesn't exist at the second time. The problem is a little comic.

 So I guess, whether the problem is related to process. I don't quite understand the process in White.

Thanks a lot !

Mar 29, 2010 at 8:34 AM

Thanks deepban74. I have tried your code.

 The windowA is null.  This is not a modal window, only the nomal window.

  By logstruture(), there is no problem to find the window and button. Only by clicking button, exception

  occurs. After the first time of the exception, I have written another test case, when the two case run sequently.

 The exception doesn't exist at the second time. The problem is a little comic.

 So I guess, whether the problem is related to process. I don't quite understand the process in White.

Thanks a lot !

Coordinator
Apr 10, 2010 at 2:57 PM

can you also post the exception stack trace?

 

Apr 23, 2010 at 12:10 PM

Thanks, this my exceptions.

COI.PharmaSuite.Autotests.SearchOrdinaryDocumentsTest.SearchByDocumentName:
Bricks.BricksException : Error invoking Button.Click
  ----> White.Core.UIItems.UIActionException : Window in still wait mode. Cursor: Wait, after waiting for 5000 ms

 

bei Bricks.RuntimeFramework.ReflectedObject.Invoke(MethodInfo methodInfo, Object[] arguments)
bei Bricks.DynamicProxy.DynamicProxyInterceptors.Process(IInvocation invocation, InterceptContext interceptedContext)
bei White.Core.Interceptors.CoreInterceptor.Intercept(IInvocation invocation)
bei Castle.DynamicProxy.AbstractInvocation.Proceed()
bei ButtonProxya4f1085589514f77949cc56314b84749.Click()
bei COI.PharmaSuite.Autotests.HelperMethods.ClickButtonWithName(Window win, String buttonName) in C:\CVS.bfclassic.src.autotest\src\autotest\dotnet\UITest.Pharma\HelperFunction\HelperToFindControls.cs:Zeile 749.
bei COI.PharmaSuite.Autotests.SearchOrdinaryDocumentsScreen.SearchByDocumentName(OrdinaryDocument ordinarydocument) in C:\CVS.bfclassic.src.autotest\src\autotest\dotnet\UITest.Pharma\Screen\SearchScreen\SearchOrdinaryDocumentsScreen.cs:Zeile 50.
bei COI.PharmaSuite.Autotests.SearchOrdinaryDocumentsTest.SearchByDocumentName() in C:\CVS.bfclassic.src.autotest\src\autotest\dotnet\UITest.Pharma\TestCases\SearchTestSuite\SearchOrdinaryDocumentsTest.cs:Zeile 59.
--UIActionException
bei White.Core.UIItems.Actions.Action.<Handle>b__2()
bei Bricks.Core.Clock.Perform(Do do, Matched matched, Expired expired)
bei White.Core.UIItems.Actions.Action.Handle(Window window)
bei White.Core.UIItems.WindowItems.Window.ActionPerformed(Action action)
bei White.Core.InputDevices.Mouse.ActionPerformed(ActionListener actionListener)
bei White.Core.InputDevices.Mouse.Click(Point point, ActionListener actionListener)
bei White.Core.UIItems.UIItem.PerformClick()
bei White.Core.UIItems.UIItem.Click()

 

 

Coordinator
May 18, 2010 at 5:06 AM

Button click operation is considered done when the mouse returns back to its original non-wait state. Seems like at the end of 5 seconds the mouse is still showing hour glass or something. Is that true?

May 18, 2010 at 7:38 AM

Yes. In the system, the button "Suchen" of window is waiting until the dialog window is closed, After that,  the button is enabled again.

May 20, 2010 at 7:23 PM

In that case you should increase the wait timer in the app.config

 

or switch to White 0.20 and try the custom wait mechanism

 

Throndorin