Anchor Base UiPath Activity Example

Anchor Base Example

Editors Note: Many students have asked for guidance on the UiPath Anchor Base activity, and how it works with the Find Element and Find Image functions. We’ve always been fans of Anders Jensen, and we recommend this video fairly often. We’ve embedded it here and provided a mildly edited transcript of the video to help users get the most out of the content. Enjoy the video, and subscribe to Mr. Jensen’s YouTube page if you get a chance.

In this UiPath Studio anchor example, we will learn how to use the UiPath anchor base activity.

What is a UiPath Anchor Base?

A UiPath anchor base activity helps to locate elements on a page based on their relative positions. Sometimes webpages or PDF files do not uniquely identify UiElements with IDs. Or, the IDs may change over time. To overcome the fragility problem with UiPath selectors, a UiPath Anchor Base activity can be used.

The UiPath Anchor Activity is useful when the developer does not have a reliable or predictable selector.

Let me show you a UiPath Anchor Base example.

How to use the Anchor Base activity

To use the UiPath Anchor Base activity, follow these steps:

  1. Add the UiPath Anchor Base activity to your workflow
  2. Target an anchor with UiPath’s Find Element or Find Image activity
  3. Specify the relative position to the target UiElement with the AnchorPosition property
  4. Add the activities to be performed in the Drop Action Activity Here swimlane of the Anchor Base activity

Anchor Base in UiPath Example

I opened this RPA challenge website and there is an input field we would like to target with the UiPath Type Into activity. Let’s type something like ‘road’ into the address field.

Just quickly run the workflow in UiPath Studio to verify that the Type Into activity works without even the need for a UiPath Anchor Base activity

Problems with UiPath Selectors

However, RPA applications that do screen scraping or rely on well-formed HTML and IDs will often run into problems with a basic UiPath selector.

To fix this problem and harden our applications, we can employ the UiPath anchor base activity.

Delete what we have on the current workflow. Then search for the anchor base activity in UiPath Studio’s Activities panel. Then drag the anchor base activity onto the workflow. You always create an anchor base close to your target.

So let’s add our Type Into activity here as the UiPath Anchor Base action to perform.

Then we will indicate the address field. We can type in ‘road’ again.

Then we will have an anchor that’s close to the address field.

We will just take the address label, because that will always be close to the target field.

The best thing to do is just take this address because that will always be close to our field.

UiPath Anchor Base Activity
The UiPath Anchor Base activity can be used to overcome the fragility of PDF and HTML selectors.

Find element vs find image

We can choose two UiPath find types in our anchors: Find Element and Find Image.

Always try Find Element first. If that doesn’t work, you can use the Find Image.

Drag the Find Element activity into the UiPath anchor base acivity.

That will be the address here.

Anchor Base AnchorPosition

Now we choose the Anchor Base position by specifying the AnchorPosition property.

The chosen anchor is over the target of our Type Into activity, so the Anchor Base AnchorPosition should be on top.

You can see that that the position changes in the UiPath Studio worfklow.

So now we have our AnchorPostion set to top. We can now run our UiPath Anchor Base example application.

Run it two times to verify it works on different sides.

UiPath Anchor Base Find Image

But what if the find element didn’t work? The UiPath Find Element and Find Image activities compliment each other. If the Find Element fails, you can always try the UiPath Find Image activity.

And what we’ll do is that will indicate our anchor base image to be the address JPG. Besides the use of a JPG, GIF or PNG as the target, the UiPath Find Image Anchor works the same way as Find Element does.

Run the RPA application and you’ll see that it works exactly the same as before. And that’s a full UiPath Anchor Base tutorial to demonstrate how to improve on the basic selector functionality provided with UiPath Studio.

Anchor Base Resources

More information on how to use the UiPath Anchor Base activity can be found in the production documentation.

The sharing of Anders Jensen’s content should not be interpreted as his endorsement for this site. We just like his content, and we hope he likes ours too.

Find more from Anders Jensen on his webpage.

UiPath on Twitter
UiPath OCR Example on YouTube
Here's how to take UiPath OCR to the next level. Check out this UiPath Youtube video from @cameronmcnz.

#UiPath #UiPathCertified #RPACertified #RPA #RPACertification #UiPathExample