Ranorex Spy "Track" API

Best practices, code snippets for common functionality, examples, and guidelines.
aromney
Posts: 2
Joined: Wed Jan 03, 2018 6:12 pm

Ranorex Spy "Track" API

Post by aromney » Thu Jan 04, 2018 5:02 pm

I'd like an API to begin the "Track" process normally performed through a manual Ranorex Spy GUI button press. This would allow my application to get a RanoreXPath from a mouse click on a UI element. Additionally, it'd be nice to also be able to use Ranorex Spy's GUI highlighting without having to initiate it from Ranorex Spy application GUI.

I think this could be described by an API to:

-Begin Ranorex Spy Tracking
-Callback for UI element object selection/mouse pointer down where the path, at a minimum, is passed to any listeners
-Highlight object at path

Does this already exist?

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Ranorex Spy "Track" API

Post by McTurtle » Fri Jan 05, 2018 2:57 pm

Hello aromney,

Sure, it exists, that's why Ranorex can do it. However, I am sure that what you are asking for is a Ranorex trade secret and therefore won't be revealed :)

Regards,
McTurtle

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3908
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Ranorex Spy "Track" API

Post by odklizec » Fri Jan 05, 2018 3:31 pm

Hi,

Check this post about highlighting an element via code:
https://www.ranorex.com/forum/is-it-pos ... tml#p39458

However, this post is well over a year old and so the code may need to be updated to make it functional with Ranorex 7 or 8.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Ranorex Spy "Track" API

Post by krstcs » Fri Jan 05, 2018 4:22 pm

The PUBLIC API is here Ranorex API Documentation.

If what you are looking for is not in there then it is not supported for use by Ranorex.

I would think that generating a RanoreXPath at runtime would not be terribly difficult, but I wonder why you would need it. It seems to me that there may be a better way to configure your tests so that you don't need this. I do some very technical testing, but I've never needed to get XPaths at runtime, and actually I think it would be better to test if you get the XPaths beforehand.

As for the highlighting, as Pavel said, that has already been discussed and it should still work in 7/8. However, again, I would wonder at the usefulness of such a test feature as normally the point of test automation is to run without a human even looking at it beyond the final reports. It seems to just add a layer of brittle code to your tests that must then be maintained when it may not be actually necessary.
Shortcuts usually aren't...

aromney
Posts: 2
Joined: Wed Jan 03, 2018 6:12 pm

Re: Ranorex Spy "Track" API

Post by aromney » Fri Jan 05, 2018 11:24 pm

In retrospect, I should have submitted this topic to "Automation API".
odklizec wrote:Check this post about highlighting an element via code:...
Cool, this answers one of my questions and provides a starting point for the others.
McTurtle wrote:Sure, it exists, that's why Ranorex can do it. However, I am sure that what you are asking for is a Ranorex trade secret and therefore won't be revealed :)
This shouldn't be the case because what I'm asking for does not require knowledge about any inner workings at all. I want a dll that let's me get a small subset of the information provided by the Ranorex Spy application but without the GUI. Definitely no secrets revealed when peeling off a GUI layer.
krstcs wrote:The PUBLIC API is here Ranorex API Documentation.

If what you are looking for is not in there then it is not supported for use by Ranorex.
Noted!

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

Re: Ranorex Spy "Track" API

Post by Support Team » Mon Jan 08, 2018 4:06 pm

Hello aromney,

There is a method available that you could use in order to get an element during runtime based on where your mouse is currently located:
- FindFromPoint: Link

In code the usage could look something like this:
Element button = Host.Current.Element.FindFromPoint(Mouse.Position);
From this, you can then build the RanoreXPath:
RxPath Path=button.GetPath(PathBuildMode.Default);
Available modes: Link

I hope this helps.

Sincerely,
Tomaž
.
Image