How to add condition depending on the attribute class from a webpage

Hello! So I am new to UiPath studioX, and I’m working on an automation that pulls computer names from excel and uses them to either extend or delete depending on the last heartbeat within a webpage. I have been trying to create a condition where it extracts the class of the color from the last heartbeat in the webpage and furthermore delete it if the class states “has-text-danger” which is represented by red, and extend it if the class states “has-text-success” or “has-text-warning”, which are green and yellow. I am struggling creating and IF condition for the class, as it is a string, and not a boolean. I am attaching some context in images.

Hi @Enrico_Porcella

You can use Get Attribute Activity to get class text value then in If activity you can compare the value as string

ElementClassValue.Trim.Equals("your class text")

If class element has more than one class, you can use Contains Method

ElementClassValue.Trim.Contains("your class text")

Cheers

I have tried this already. The thing is that the page refreshes every time an element is deleted or extended and it can just do one at a time. I have it set for it to do the action in the second row right below to Last Heartbeat and then refreshes and does the action again with the new element in the second row, but when I run the process, it only either extends or delete all the devices. It doesn’t determine the class of the new element first and the proceed to perform the action. What can I do in this case.
Screenshot (6)

Thanks in advance,
Enrico

Oh I got it.

is it possible to get the class attribute again and check it before do the action ?

Also, you can try For Each UI Element Activity and indicate the list and add a IF activity to check the class or other attribute to compare like this

CurrentElement.Get("class").ToString.Contains("has-text-success")

Cheers

It does the work for only the first time, then it says “Source data was modified, the UiElement is no longer valid.” How can I set it up so it refreshes every time, so it can perform the action several times, or what can I do in this scenario.

When I perform the action, it either deletes or extend it based on the first action performed. Instead of performing it based on the current element that is on top, it just takes the first action and repeats it. How can I make it so that after every refresh, it finds the element again and perform the action based on its class. For instance, how would I be able to check the class again and check it before performing the action