Add attributes to the selectors on runtime

Hi There,

I am trying to add a ‘class’ attribute for the UiElements of output from Find Children activity (selector for each of those output elements from the activity doesn’t include the class attribute), but haven’t been successful in doing so. Just wondering if it is possible to add it during a run time under for each loop as in below screenshot with an assign activity to update the selector. Any suggestion would be helpful.

Thanks,
Rammohan B.

Never tried this, but I think you can use InvokeMethod

item.Set("class","ClassName")

Thanks for the reply @vvaidya, Invoke method doesn’t seems to be working.

Thanks,
Rammohan B.

TargetObject:item
MethodName:Set

Pass class and value in parameters.Search forum for further info on InvokeMethod

1 Like

Thanks @vvaidya . Looks like the ‘Invoke Method’ won’t work in my case.

Putting it in another way, so this is what i have been trying to do.

  1. Using ‘Find Children’ Activity to retrieve all the button elements inside a section.

  2. Using ‘For Each’ Activity to loop through all the elements found and perform
    a. ‘Click’ Activity on the button. (As soon as this is clicked, the class of the activity changes from ‘btn btn-default’ to ‘btn btn-success’ in couple of second)
    b. ‘Wait Attribute’ Activity to wait until the ‘class’ changes to ‘btn btn-success’.
    However here is the problem, ‘Wait Attribute’ never receives the updated ‘class’ attribute. Its always ‘btn btn-default’ due to which the for each loop never continues. Looks like the ‘Find Children’ activity stores all the details related to its children elements during its initialization itself instead of accessing on run time when that particular element is accessed.

Workflow Screenshot:
image

In the initial case for 2.b i wanted to use ‘Wait Element Vanish’ activity to continue the loop when that element no longer exists. But in that case since ‘class’ attribute was not identified as one of the selectors for ‘item’, i was trying to add it during run time.

I hope the problem is properly explained :slight_smile:

Thanks,
Rammohan B.

Try “find element” after the click which basically should get the updated selector.

Pass “item.Selector.ToString” into selector

And “item” into Output.

Thanks,

Vinay

1 Like