Anchor Behavior in Modern Activities

What is the logic used by the bot to find an element when when using anchors in modern activities?
I understand that an anchor will help identify an element that is near it, which is especially useful if there are multiple elements that can’t otherwise be uniquely identified, but what logic is used to determine whether an element is near an anchor?
I’m nervous about using anchors if I can’t predict how they will behave.

Hi @danred99

The anchor-based approach works best in consistent layouts where the relative positions of elements do not change frequently. If the UI layout is dynamic and elements shift around, the bot might struggle if the anchor-target relationship is not clearly defined.

You can also fine-tune the search by adjusting the allowed distances or tweaking the selector if necessary.

Thanks,
Muthuraj

@danred99,

Anchor is not about how close or far it is from the target UI element. It’s about stable UI element. The anchor should be stable so target element will be identified by it accurately.

Thanks,
Ashok :slightly_smiling_face:

Thanks for this info. How do I tweak the allowed distances?

Thanks for this clarification, however it seems to deepen the mystery of how anchors help distinguish target elements that are otherwise identical.

In my case, a web page has a list of radio buttons that all have the same tag, class, and name (no inner text). Visually, there is a label (div tag) next to each one that distinguishes them. I need to click a specified radio button, but I can’t identify it by the radio button tag alone. I thought I could use an anchor to identify, since the identifying text is right next to it.

@danred99,

As I understand, there is not inner text to the radio buttons. Here you can use Find Children activity to get all radio buttons and then Click on the radio button number like 3rd or 4th as per requirement.

I feel there would be some kind of sequence or hierarchy the website would have to identify which radio button is checked.

Thanks,
Ashok :slight_smile:

I considered this and it sounds like it may be what I have to do; i.e., use Find Children then either click the radio 2nd radio button or find the radio button that is next to the text I’m looking for.

Either way, I’d still like to get a better understanding of how anchors work. I’m becoming convinced that they are not much use for anything.

It is, actually. Rather than saying “close or far” it’s about the underlying structure of the object model.

Anchors are exceptionally useful for web pages or applications where the selectors themselves don’t allow unique identification of the object you need to interact with.

Here is an example:

image

The buttons cannot be uniquely identified with just a selector for the button. To get the automation to click the correct Generate button, I used an anchor on the text in the second column.

This is nearly identical to my situation. I experimented a bit with anchors and they seem to be working well. I still haven’t received a clear answer to my question; i.e. what is the logic for how anchors help identify a target.

@Bogdan_Sultana may be able to answer that for you Dan.

I still haven’t received a clear answer to my question; i.e. what is the logic for how anchors help identify a target.