Ranorex can not find control

Ask general questions here.
this_is_ridiculous
Posts: 27
Joined: Tue Apr 27, 2010 10:33 pm

Ranorex can not find control

Post by this_is_ridiculous » Tue May 11, 2010 12:14 pm

Hi!
I've got an issue. Ranorex can not find the element during runtime. However the element can be found within the Element browser.I search for the button. It's hierarchy doesn't seem to be too deep but control can not be found even within 100 seconds of search timeout. The control is searched over transparent custom window that host dotNet controls. I've tried disabling transparency but still no results.
i'm using version 2.3.

Does anybody have any suggestions to solve the problem?

Thanks in advance.
Artem.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex can not find control

Post by Support Team » Tue May 11, 2010 5:54 pm

Is there a warning message in the Ranorex report file?
Please, post the complete exception text and the path of the item! Or even better: a snapshot of your application and the name of the item that is not found.
this_is_ridiculous wrote:i'm using version 2.3.
Have you already updated to version 2.3.1? If not, please do that :-)
http://www.ranorex.com/download.html

Regards,
Alex
Ranorex Support Team

this_is_ridiculous
Posts: 27
Joined: Tue Apr 27, 2010 10:33 pm

Re: Ranorex can not find control

Post by this_is_ridiculous » Wed May 12, 2010 5:19 pm

Hi!
Sorry, but i can't post the snapshot of an app or the screenshot of the app or the even the screenshot of the exception because i'll break the contract rules if i do that. The only thing i can tell is that app is Autodesk Autocad Map 3D 2011 and it's still not shipped. I could post all the needed information when the product is shipped. All i can tell right now is the app uses layered windows (transparent). Still Ranorex Studio element browser displays the needed control but can not find it in runtime. If i use full xPath of the control like:

Code: Select all

Button autoScrollBtn = "/form[@title='_MAPDATATABLE']/element[@controlid='59423']/element[@controlid='16723']/element[@controlid='29']/controlnet11[@controlname='ControlAxSourcingSite']/controlnet11[@controlname='toolStripTop']/toolbar/button[@accessiblename='Auto-Scroll']";
the ElementNotFoundException is thrown after 10 seconds search timeout.

if using

Code: Select all

Button autoScrollBtn = wTable.FindSingle("//element[@controlid='59423']/elementelement[@controlid='16723']/element[@controlid='29']/controlnet11[@controlname='ControlAxSourcingSite']/controlnet11[@controlname='toolStripTop']/toolbar[@accessiblerole='ToolBar']/button[@accessiblename='Auto-Scroll']", 100000);

with 100 seconds of search duration it still throws ElementNotFoundException. Even if search for more deeply located control in the path specified above i still get ElementNotFoundException.


Now about the report file. To be honest i don't know what is that :) . If it's something close to repositories, well we don't use the repositories at all. All of the code is written by me.
Last edited by this_is_ridiculous on Wed May 12, 2010 5:48 pm, edited 1 time in total.

this_is_ridiculous
Posts: 27
Joined: Tue Apr 27, 2010 10:33 pm

Re: Ranorex can not find control

Post by this_is_ridiculous » Wed May 12, 2010 5:34 pm

this is the exception message if using the second button declaration
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Ranorex.ElementNotFoundException: No element found for path '//element[@controlid='59423']/elementelement[@controlid='16723']/element[@controlid='29']/controlnet11[@controlname='ControlAxSourcingSite']/controlnet11[@controlname='toolStripTop']/toolbar[@accessiblerole='ToolBar']/button[@accessiblename='Auto-Scroll']' within 1.6666666666666667m.
at System.RuntimeMethodHandle.InvokeMethodFast
at System.Reflection.RuntimeMethodInfo.Invoke
at System.Reflection.RuntimeMethodInfo.Invoke
at System.Reflection.MethodBase.Invoke
at Map_3D.Map_3D.<Button1Click>b__0 in c:\Users\auto\Documents\RanorexStudio Projects\ADSK_Blackbox\Map 3D\Map 3D.cs:line 121
at System.Threading.ThreadHelper.ThreadStart_Context
at System.Threading.ExecutionContext.Run
at System.Threading.ThreadHelper.ThreadStart
Don't look at the reflection and threading mentioned in message. Everything except searching for controls on that toolbar works fine.

If i drag the button to the code from Element browser i get this:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Ranorex.ElementNotFoundException: No element found for path '/form[@title='_MAPDATATABLE']/element/element/element/controlnet11/controlnet11[@controlname='toolStripTop']/toolbar/button[@accessiblename='Auto-Scroll']' within 10s.
at System.RuntimeMethodHandle.InvokeMethodFast
at System.Reflection.RuntimeMethodInfo.Invoke
at System.Reflection.RuntimeMethodInfo.Invoke
at System.Reflection.MethodBase.Invoke
at Map_3D.Map_3D.<Button1Click>b__0 in c:\Users\auto\Documents\RanorexStudio Projects\ADSK_Blackbox\Map 3D\Map 3D.cs:line 121
at System.Threading.ThreadHelper.ThreadStart_Context
at System.Threading.ExecutionContext.Run
at System.Threading.ThreadHelper.ThreadStart
May be it's because of window nature? It's a custom window with overriden style. it uses side caption and can change it's opacity. Still don't get it... :?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex can not find control

Post by Support Team » Fri May 14, 2010 9:27 am

this_is_ridiculous wrote:Now about the report file. To be honest i don't know what is that
Ranorex uses a report file to print out warnings, errors, and informative messages if you configure it to do so. See the corresponding chapter in the Ranorex User Guide:
http://www.ranorex.com/support/user-gui ... gging.html
this_is_ridiculous wrote:May be it's because of window nature? It's a custom window with overriden style. it uses side caption and can change it's opacity.
That should not be a problem. If Ranorex can find an element with Ranorex Spy/Studio, then you can do that by runtime as well. There must be a problem in the setup of your Ranorex test code. From the error you posted I see that you use threads to execute Ranorex code. Please, make sure that all threads use an STA apartment state (see MSDN documentation).

Another thing I noticed from the path you posted: Is this application implemented using .NET 1.1 controls? If not, then Ranorex has problems identifying Windows Forms 2.0 controls inside your application. This can be a security issue: Please, make sure that neither the Ranorex executable, nor the automated application reside on a network drive or in an encrypted folder and that both applications are started with the same user rights (same user accounts)!
Another possible cause are 32/64 bit issues, but these should be taken care of automatically if you use an installed version of Ranorex 2.3. Are you working on a 64 bit operating system? Do you get any technology limitation warning popups?

Regards,
Alex
Ranorex Team

this_is_ridiculous
Posts: 27
Joined: Tue Apr 27, 2010 10:33 pm

Re: Ranorex can not find control

Post by this_is_ridiculous » Wed May 19, 2010 2:04 pm

The first thing is THX for your support.
The second thing: yes all the threads come with STA appartment state
And the Third thing is it seems that i've figured out the problem.
Let's assume we have layered window. It has lot's of panels and other controls to perform layout propely while resizing. On top of these panels we have a button. Let it be

Code: Select all

Button autoZoomBtn = "/form[@procesname='someprocess']/element/element/element/button[@controlName='autoZoomButton']";
NOTE: in my code all the elements are folowed with their IDs
and a form

Code: Select all

Form someForm = "/form[@processname='someProcess']";
I tried searching for button through the form and all my tries failed with ElementNotFoundException no matter what search duration it was. (see my previous posts).
Button autoZoomBtn = someForm.FindSingle<Button>("//button[@controlName='autoZoomButton']");

Then i tried searching for control through the instance of desktop object and the search succeeded. But the search takes much more time than search on the window... :?

May be there's some kind of bug in searching through elements? Or may be it's still because of window nature?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex can not find control

Post by Support Team » Wed May 19, 2010 4:53 pm

this_is_ridiculous wrote:May be there's some kind of bug in searching through elements? Or may be it's still because of window nature?
I don't think this is a bug - it just looks like the button is not located inside the form your are searching. That's probably because in order to make the button transparent, the developers needed to put it on a separate top-level form.

Try analyzing that button with Ranorex Spy and check whether it is a child/descendant of the form you are searching in. If it is not, that use the absolute path to search for the button or the actual parent form!

Regards,
Alex
Ranorex Team