How to click on an Element (Image or Button) next to a particular Text element

Hi everyone,

I would like to click on a particular element that is next to a certain text element.
The particular text element to be selected is found dynamically through a Google Spreadsheet and is set in a variable.

I am making use of the Get Ancestor and Find Children property, along with the UI Explorer to find a static set of attributes for the Selector.

However, every time I reload the browser page, I get an error saying “Could Not Find UI Element”

I am using For Each loop and a counter to select the particular element to be clicked but this process fails in the case when the text is dynamically decided.

I have tried using Find Relative activity too, however I get an Activity Timed Out Exception in that case.

Is there a method using HTML tags to inspect a source and find a particular child element of the parent element of the text to be found? Can someone please guide me on how to go about this?

Thanks in advance!

Did you tried using Anchor Base activity?
Also try trimming the data before passing it to the selector!

Thanks for the prompt reply.

No, I haven’t used the Anchor Base activity. How can I implement that?
My text changes each time, so will this activity take care of those changes?

What exactly do you mean by trimming the data?
I am passing only the static components to the selector, which I have selected by trying multiple test cases for selecting the UI Element

What I mean to say is that the certain text element that you have stored in a variable, try trimming that variable by using .trim function, what happens is that when you get text sometimes it has leading or trailing space, to remove that we use trim function.
So try doing that. Also try anchor base:

In the find element indicate the text element and make it’s selector dynamic and then use click to click whatever item you want.

Got it. I will try it out. Thanks for the prompt reply

1 Like

Hi @Niket_Ghai,

I tried using Anchor Base and Trim as well but every time the text variable changes, the selector is unable to identify the UI element corresponding to the text.

All components of my selector are static except for the aaname field.

In my selector, I have assigned :

where strin is my variable that holds the variable text.

The anchor base activity works as long as the text remains constant, and gives an Activity Timed Out exception for the Find Element activity as soon as the text is modified.

Please attach the whole selector! :slight_smile:

Hi @Niket_Ghai,
I modified certain selector elements and the activity started to work.
Thanks for your help

1 Like

Cool. Happy to help :slight_smile:

1 Like