Anchor not working - selector still valid after website change

Hi.

Activity used: UiPath.UIAutomationNext.Activities.NGetAttribute

So as I have learned Anchor could be used as a extra security so that the correct element is selected when a website changes the position on a specific field/box.

I experimented with this by using devtools(F12) and changing the parameter name for an element. Based on my change the selector should not work. But the selector was valid and fetched the attribute for the field/element below instead. Why is this happening I mean the anchor is meant to prevent stuff like this right?

How does the anchor even work, does it look on element relative to where it is?

What is the issue here, because currently the anchor is pointless and provides no “extra security” at all, is it just inconsistent, because this has worked before. Do you need to create multiple anchors on the same target or indicate different places? Feel like it was more stable with classic activities?

Or im maybe just doing it wrong. Does anchor work with strict selectors if not which selector types does anchors work with?

@atomic

Let me explain…when you indicate a anchor…the anchor is searched and then the base which is the actual selector element you are giving is searched from the anchor…

For example if you have give tag a as anchor and give tag B as base…then tag A is search and say if there are two tag B’s then based on the given selector of tag B or base the actual element is identified…in your case if there is no other element which matches the base selector then by default only the one which you have selected would work even with the change

Cheers

1 Like

To exactly evaluate why your selector should not work, you’d need to provide examples.

To find out how an anchor works, it always helped me to consult the UiPath Documentation here:

Also it’s not that you MUST always use an anchor. Sometimes Studio finds auto-anchors, that I’d never use personally. You are the one building the robot and selectors and you should find out how your application performs and works.

Basically, if you set a strict selector it always has priority over any other selectors and the other selectors are used like a fallback method (there is a good graphic displaying exactly that in the documentation). Also for a strict selector it is usually always either you find the selector or you don’t find it. To me personally up to this day I find strict selectors the best selectors to use, because I can enhance them with variables and regex (you can do that in fuzzy too, but just makes more sense to me to use it in strict). Strict selectors can work without the use of anchors, but fuzzy should always have an anchor set, because if fuzzy finds more than one selector(match) the anchor can help to locate the correct selector. Also @Anil_G already explained how anchor works or from where it is searched from :slight_smile:

Hope this helps and otherwise maybe you can share your descriptor/selectors so we can help and evaluate your exact problem.

1 Like