Can we disable Spy's "best matching element" result?

Ask general questions here.
User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Can we disable Spy's "best matching element" result?

Post by Aracknid » Wed Feb 20, 2013 5:55 pm

I noticed today when I was using Spy that sometimes it gives a result and it says on the bottom in the status area "No elements match the RanoreXPath. The best matching element has been selected instead."

I like to use Spy to make sure things are NOT there and I find this confuses me. Is there a way to turn this off so that no matches will display nothing in Spy?

Also, does this happen in code? If I'm using TryFindSingle and expecting nothing, will it sometimes return the closest match? That would be bad... Just wondering.

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

Re: Can we disable Spy's "best matching element" result?

Post by Support Team » Thu Feb 21, 2013 11:45 am

Hi Aracknid,
If you use a path which has no matching result elements in Spy, the element which was found last while evaluating the path is selected (so basically matching not the path, but a prefix of the path). In most cases this means that the best matching element would be an ancestor element of the element you are looking for.

We did this to help users identify the location where things might have gone wrong, and help out with fixing the path in question.
This does not in any way affect automation code, the (Try)Find() methods always return elements matching the path and not anything else.
I understand why this might be a bit confusing, so we we'll consider tweaking this a bit to clarify things.

Michael
Ranorex Team
.
Image

User avatar
Aracknid
Posts: 342
Joined: Tue Aug 10, 2010 3:23 pm
Location: Toronto, Ontario, Canada

Re: Can we disable Spy's "best matching element" result?

Post by Aracknid » Thu Feb 21, 2013 2:41 pm

Ah, I see. That makes sense.

Actually though in my case, I'm finding the element that is last in my path because I also have a function on it, such as "/div[@ID='MyID' and x()>0]" so it finds the div even if it's x value is 0, except of course tells me it's the closest matching one.

Aracknid