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.
Can we disable Spy's "best matching element" result?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Can we disable Spy's "best matching element" result?
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
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
Re: Can we disable Spy's "best matching element" result?
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
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