In the UiPath documentation UI Automation, it is mentioned that I should avoid using the idx attribute unless its value is a very small number like 1 or 2 in the selectors. But why should we avoid it? Also why it can be used if it is a small number?
In the selectors, why should I avoid using the idx attribute unless its value is a very small number like 1 or 2
Usually idx attribute is assigned to generated data on websites. If it’s a small number it can be related to some headers or simple buttons. If number is big then such attribute can be part of one from many similar elements. For example if you have a website where there is a dynamic table with 100 items and each item have it’s own idx. The problem is that usually these tables have those indexes randomly attached to each element and you can’t be sure that if you will use selector with the “idx = 45” it will work with exact same item on the next run. Hopefully it make sense
Hi. Yes. This is a bit helpful. How is this attribute generated? Where can I learn more about this?
This attribute is generated automatically when there is nothing left in your “original” selector which can help you. That’s why using this index is a tricky case. If there is nothing left for use you should try to work with an anchor which can define other element around your desired one. This can help you with building the selector which can work better.
No. I meant how the website or application generates this attribute
It’s not generated by the website. It’s a part of the UiExplorer mechanism.
Ok. Thank you