Couldn't find window in the same process

Feb 22, 2010 at 8:46 AM

Hi,

I have a problem when I try to get a new window in the same process than previous window.
I obtain this kind of error:

White.Core.UIItems.UIActionException: Couldn't find window with title Connection Wizard in process 3196, after waiting for 6000 ms
Name: Bandeau,  Bounds: 509;0;900;67 ProcessId: 2524, Modal: False
Name: Connection Wizard ,  Bounds: 1340;490;507;394 ProcessId: 3196, Modal: False
Name: Genesys Starter App,  Bounds: 1273;455;231;354 ProcessId: 3196, Modal: False
Name: Genesys Starter App,  Bounds: 844;423;231;354 ProcessId: 1844, Modal: False
Name: Boîte de réception - Microsoft Outlook,  Bounds: -32000;-32000;160;31 ProcessId: 3756, Modal: False
Name: Lot1_test - Gallio Icarus,  Bounds: -32000;-32000;160;31 ProcessId: 2804, Modal: False
 

Can you help me please?


Thanks,
Regards.

Feb 22, 2010 at 10:17 AM

Please show some code to understand which way you choose to get the window.

Can you have a look in UISpy or UIAVerify to see in which context is the window you search?

Feb 22, 2010 at 11:14 AM

Ok so,

        private void ConnexionStep6()
        {                    
            foreach (Window w in Desktop.Instance.Windows())
            {
                if (w.Name.Contains("Connection Wizard"))
                {
                    _wizard = _application.GetWindow(w.Title);
                    
                    _wizard.Get<Button>(SearchCriteria.ByAutomationId("7").AndByText("Next >")).Click();
                    ConnexionStep7();
                    break;
                }
            }
        }
        private void ConnexionStep7()
        {
            foreach (Window w in Desktop.Instance.Windows())
            {
                if (w.Name.Contains("Connection Wizard"))
                {
                    _wizard = _application.GetWindow(w.Name);
                    _wizard.Get<Button>(SearchCriteria.ByAutomationId("3").AndByText("Finish")).Click();
                    break;
                }
            }
        }

 

And half the time, it's work or it doesn't !

That's why I included this piece of code:

private void ConnexionStep6()
        {                    
            foreach (Window w in Desktop.Instance.Windows())
            {
                if (w.Name.Contains("Connection Wizard"))
                {
                    _wizard = _application.GetWindow(w.Title);
                    
                    _wizard.Get<Button>(SearchCriteria.ByAutomationId("7").AndByText("Next >")).Click();
                    int n = 1;

                    do
                    {
                        System.Threading.Thread.Sleep(1000);
                        Console.WriteLine(n + "second(s). Closed? " + _wizard.IsClosed.ToString());
                        n++;
                    } while (_wizard.IsClosed == false);

                    ConnexionStep7();
                    break;
                }
            }
        }
        private void ConnexionStep7()
        {
            foreach (Window w in Desktop.Instance.Windows())
            {
                if (w.Name.Contains("Connection Wizard"))
                {
                    _wizard = _application.GetWindow(w.Name);
                    _wizard.Get<Button>(SearchCriteria.ByAutomationId("3").AndByText("Finish")).Click();
                    break;
                }
            }
        }

It's not awful but it works!

Feb 22, 2010 at 1:15 PM
Edited Feb 22, 2010 at 1:21 PM

first:

why do you search over all windows on desktop, if the window is part of your application?

Maybe better is to use _application.GetWindows() => all windows of the application

 

if I understand correct, the window will be found but not all the time, correct?

So you have a timing problem and you should increase the timer in the configuration file.

 

See Configuration

 

If I look deeper it seems that there are different windows

ConnexionStep6 and ConnexionStep7

 

Is this correct?

 

and both have the same name?

 

if you have access to the developer, ask for different names if posswible if not different automation Id's for all windows, and than use Linq to search for window with correct Automation id

 

_application.GetWindows().Where(p=>p.AutomationElement.Current.AutomationID == "id").First();

Feb 22, 2010 at 1:35 PM

Exactly !

I like ur idea to replace Desktop.Instance.Windows() by this._application.GetWindows() ! Thanks !

They are 7 screens with the same name "Connection wizard"  and I'm stuck since I work with .Net 2.0

I ll keep this method while it works!

Feb 25, 2010 at 5:42 AM

If you have several windows with same name,look for the window interaction state property. The below piece of code may fix your problem.

 

                    foreach (Window window in application.GetWindows())
                    {
                        if (window.Name == name)
                        {
                            WindowPattern wnd = window.AutomationElement.GetCurrentPattern(WindowPattern.Pattern) as WindowPattern;


                            if (wnd.Current.WindowInteractionState == WindowInteractionState.ReadyForUserInteraction)
                                return window;
                        }
                    }

 

Feb 25, 2010 at 7:22 AM

Thanks for your help loganathan,

but I'm still work with .Net 2.0 !

And when I was looking for more informations about WindowPattern I see that this class is contained in the .Net 3.0...