Page 1 of 1

Ranorex can't see UI objects from time to time

Posted: Wed Feb 11, 2009 10:27 pm
by taralex
I started to notice a strange behavior in Ranorex.
I have pathes to the key elements of the application under test hardcoded in the repository like the following:

Code: Select all

public static Element bobcatDataBrowserForm
        {
            get
            {
                try
                {
                    RxPath path = new RxPath("/form[@controlname='MyForm']/container[@controlname='mRibbonControl']");
                    return Host.Local.Element.FindSingle(path, _timeout);
                }
                catch
                {
                    WriteLog("Element not found.");
                    return null;
                }
            }
        }
It used to work perfectly well before, but recently, as I've said, sometimes ranorex returns null while the element I'm looking for is definetely there.
If I reload the application under test, sometimes the above property returns the element I search for, but again sometimes not.. I couldn't find any pattern to when it fails to find the element. I tried using RanorexSpy at the times when this property didn't work, and I observed strange things: I could browse the tree of the application as usual, but the nodes where all empty, i.e. almost every node in the tree is named as the main form and has no attributes defined... It looked like Ranorex was able to browse the elements, but couldn't read their attributes...
it started to happen with Ranorex 2RC library and I observe the same behavior with the release dllls.

Posted: Thu Feb 12, 2009 9:25 am
by Support Team
Which type of application does this happen with? .NET Windows Forms applications, Win32, MFC, ...?

Would it be possible to get a sample application with which we can reproduce the error?

Regards,
Alex
Ranorex Support Team

Posted: Thu Feb 12, 2009 3:22 pm
by taralex
This happens with a .NET windows forms application which uses custom forms... Unfortunately, I can't give you the installation... I know it's impossible to fix a bug without even knowing where it is, I myself am still not sure if it's ranorex or the application I'm trying to automate... It happens sometimes on my laptop, but I haven't noticed it happen on a desktop pc... very strange..
I thought maybe you already had something similar andcan provide some workaround..

Posted: Fri Feb 13, 2009 2:20 pm
by Support Team
We identified a bug that could be the cause for that problem and fixed that for the upcoming 2.0.1 release. Hopefully, that fixes that problem :-)

Regards,
Alex
Ranorex Support Team

Posted: Fri Feb 13, 2009 3:53 pm
by taralex
Sounds great. Maybe the following info would help you even more:
I think I found the pattern in this behavior.
The problem occurs if I try to use the Find function during the time the application is loading.
For example, it takes the application I'm trying to automate around 10 seconds to load, therefore I use something like the following to wait until the ribbon control in this application is there:

Code: Select all

Element myForm
while (myForm == null)
{                
   try
   {
      RxPath path = new RxPath("/form[@controlname='MyForm']/element[@controlname='navigationWorkspace']/*/container[@controlname='ribbonControl1']");
      myForm = Host.Local.Element.FindSingle(path, _timeout);                      
   }
   catch
   {                    
   }
}
In this case I afterwards sometimes cannot find other elements of the same application and RanorexSpy also sees them stripped off all the attributes.
However, if I don't use the Find function's timeout to wait for an element inside the application, but just put in a Thread.Sleep (10000), the application is loaded (without being bothered by ranorex during the load) and all its elements are accessible afterwards.

Posted: Fri Feb 13, 2009 3:59 pm
by Support Team
That's exactly the behavior of the bug we fixed :-)

Regards,
Alex
Ranorex Support Team