Loop action in Get Element

I’m using the OpenRPA.Windows Get Element activity to detect a field. The activity should be detecting 4 fields.

I need to iterate on those items to type in the third. Is it possible? Maybe using the “Loop action”? I don’t know how to use that.

You have a few options.

  • use an index variable. If you select get element and create a variable called index of type int32 ( and are using the latest version of openrpa, so 1.4.57.5 or higher, there was some issues with this in older versions ) then this will get increased by one every time it loops over the body, so if you give it default value 0, the first time it loops, this will be 1, the next time it will be 2, and so on. it’s important the variable is called Index and that it is created in the activity scope
    image
    So now you can use an if activity and only do what you need to do, when index is 3

  • you can create a variable , for instance called results, and use in “elements” property of get element ( go to the field, type a name for instance results, press Ctrl+K that will auto create the variable with the right type with that name … you may need to delete it and write it again, to workflow foundation to detect the variable now exists )
    image
    after the activity ( so no inside the body of the activity ) you can then access the elements found, in the variable array ( so you can then use results(2) to get the 3rd item, since array’s normally starts at index 0 )

  • Use hidden/unsupported selector property IndexInParent. For windows you can manually add an “IndexInParent” property in the selector, to get a specific number. This number if will the be the placement in the parent for that element ( without considering any filters/selectors ) for ui’s that is very static and does not change a lot, this can be handy, but again, this is unsupported use at your own risk.

Hi,

Thank you very much, but i don’t completely understand the last part of your answer. Can you show how to do it in screenshots?

Thanks in advance

Oh, i got it. Worked.
Thank you very much.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.