Fetch Class Index using Java Script \ jquery

Hi Folks,

This is more related to Java Script. Apologies if I posted in the wrong category. But it can be quite useful in UiPath with respect to applying javascripts.

I have a webpage with multiple element instances of same Class name. What differentiates them is the classname index --> Classname[i]. innerText for each instance is unique.

I am required to fetch the “index” position of the classname using the unique “innerText”. Can you folks please help me with the java query I should execute to get the index position corresponding to an “innerText”

Thanks in advance.

can you share some sample data.
As far I did understand your classvalue (get Attribute on class attribute) is like nameA nameB nameC Or nameB nameA nameC and the position of a particular class name is needed?

In that case could help


My class name is ‘ticket-no’ (actually an HTMLCollection) and the instances go like ticket-no[0], ticket-no[1], ticket-no[2]… etc…
Now for each item in the collection (ticket-no[0], ticket-no[1]…) the unique factor is the innerText.

My input which is the innerText is clearly defined. What i am supposed to get is for which class name instance (0 or 1 or 2 or…) does my innerText input apply/match. Basically I am to retrieve the index of the HTMLCollection element for which my innerText matches.

Hope I was able to convey the requirement.