Path from a Ranorex.Control not found using spy

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
JayInMA
Posts: 10
Joined: Thu Jan 10, 2013 5:10 pm

Path from a Ranorex.Control not found using spy

Post by JayInMA » Tue Apr 16, 2013 8:13 pm

This is for Ranorex version 4.0.2.21666

In one of my tests I get a path of a Ranorex.Control that I got to by recursively walking down from the root of the winforms app. When I use that Path in RXSpy, it reports it as an invalid path. If flip things around.. and hardcode in path reported by spy, it also is invalid

Here is break down of what I have from the Ranorex.Control vs what RXSpy wants (red highlights diffs)

Path from Control
  • /form[@controlname='HomeForm']
    /container[@controlname='panelControlDetail']
    /container[@controlname='SubscriptionView']
    /container
    /container[@controlname='panel2']
    /container
    /element
    /container[@controlname='xtraTabPageContact']
    /container
    /container[@controlname='repeaterPanelAddresses']
    /container[@controlname='RepeatableMemberPhysicalAddress' and @caption='' and @controltypename='RepeatableMemberPhysicalAddress' and @instance='0']
Path from RXSpy
  • /form[@controlname='HomeForm']
    /container[@controlname='panelControlDetail']
    /element
    /container
    /container[@controlname='panel2']
    /element
    /element
    /container[@controlname='xtraTabPageContact']
    /element
    /element[@controlname='repeaterPanelAddresses']
    /element[@controlname='RepeatableMemberPhysicalAddress' and @instance='0']
I am at a loss.. Why are they not working with each other, why so many different usages of element and container

- Jason

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Path from a Ranorex.Control not found using spy

Post by Support Team » Wed Apr 17, 2013 1:26 pm

Hi Jason,

This should normally not be the case, the RxPaths should be equal whether you track the control with Spy or during Recording.

Could it be that the .Net 4.0 extended version is not installed on your machine and that your AUT is a WinForms application created with .Net 4.0?
If so please install .Net 4.0 extended and reinstall Ranorex after you installed it, by the way the new Ranorex version is available. Please update to the new version and please use the setup.exe or the Ranorex-X.exe, because this will ensure that the prerequisites will be installed too.
The new version can be downloaded here: Rx 4.0.3.
If this shouldn't solve the issue please post a Ranorex snapshot file of that control.
Following link will show you how to generate a snapshot file: Creating Ranorex Snapshot Files.

Regards,
Markus
.
Image

JayInMA
Posts: 10
Joined: Thu Jan 10, 2013 5:10 pm

Re: Path from a Ranorex.Control not found using spy

Post by JayInMA » Tue Apr 30, 2013 3:56 pm

I created a test program that shows the issue and have attached it to this post.

Core of the program is in the method runtree(Adapter rxAdaptor)
It starts at top of form, and using recursion walks all the Adapters and their children saving the reported RXpath.

1) Run Program..
2) Press "Find Paths"
the lower right window fills with paths found
3) Press "Check Paths"
runs through all found paths and attempts a Unknown f = Host.Local.FindSingle(foundPath) to validate the paths work.

4) Start Ranorex Spy
5) Pick one of the paths from lower right window (ie "/form[@controlname='Form1']/container[@controlname='panel2']/button[@controlname='button11']" )
6) Paste into Spy and try and resolve
it fails

Not sure what is going on here
Attachments
Form1.Designer.zip
Testing App to show paths reported by RX in code don't work in Spy
(11.58 KiB) Downloaded 199 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Path from a Ranorex.Control not found using spy

Post by Support Team » Wed May 01, 2013 12:34 pm

We analyzed that problem using your sample app. This seems to be a special case in the WinForms object recognition that Ranorex does not handle correctly: You automate the WinForms control within the same process from the same process. This works, but as soon as you then try to automate the same controls from another process, the WinForms controls are no longer recognized. That's why Spy does not recognize the controls correctly any more if you first access them using Ranorex from within the application.

Basically, automating controls within the same process is not a use case Ranorex is designed for. You can simply do unit testing in that case since you can directly access controls within the same process.

If you still want to use Ranorex for that use case (although not recommended), always make sure to use a thread different from the main Window thread for performing Ranorex actions.
In your sample app, the "Check paths" button performs Ranorex actions that access controls from the main window thread within the window thread. That may cause deadlocks!

Anyway, we will fix the object recognition for this special case with the next minor version.

Regards,
Alex
Ranorex Team
.
Image

JayInMA
Posts: 10
Joined: Thu Jan 10, 2013 5:10 pm

Re: Path from a Ranorex.Control not found using spy

Post by JayInMA » Wed May 01, 2013 1:36 pm

Thanks for taking a look..

What we have done is created a tool that runs in same process to find all the paths for controls on a form and that tool helps us quickly create wrapper class for our forms.( This basically, makes a 'skin' for our test writers that makes it feel closer to the actual thing they are writing tests for. )

We then write unit tests that run with Nunit (ie external process) that gets controls

public class MyFormWrapper
{
public Ranorex.Button MyButton
{
get
{
return Host.Local.FindSingle<Button>("/form[@controlname='Form1']/container[@controlname='panel2']/button[@controlname='button11']")
}
}

}

We are actually having no run time issues at all with the generated paths.. we just noticed that if we use path from RXSpy.. it does not work.. and if we paste into RXSpy we get the error you see

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Path from a Ranorex.Control not found using spy

Post by Support Team » Wed May 01, 2013 2:45 pm

JayInMA wrote:We are actually having no run time issues at all with the generated paths.. we just noticed that if we use path from RXSpy.. it does not work.. and if we paste into RXSpy we get the error you see
OK, this should be fixed in the next minor version Ranorex 4.1 then :D

Regards,
Alex
Ranorex Team
.
Image