Selector - The best practice for replace "idx"

Hello everybody,

I want replace idx attribute for other more fiable.
What is the best practice ?

Thanks !

Hi @mateo.drouillard

You can also try to use Asterisk ->* (But it is not recommended) or You can use Counter variable to increment the idx value. Based on the requirement we can modify it.

Do you have any problem with the selector?

Regards
Gokul

Example @mateo.drouillard

Here idx attribute value will keep on change when you reopen the website again.

1 Like

If you still have other HTML tags left for adding in the selector, then I would suggest to add them first till IDX is gone on its own. If it is still there, it should have a value of 1 or 2, if not then that is not a ideal selector and you should go for Anchor based activity and use some other stable UI element to locate your current UI element.

1 Like

There isn’t really a best practice. It depends on the system you’re using. Just use attributes that don’t change, and when you get it right so the selector is unique then idx won’t be needed.

1 Like

idx should be avoided if possible. Incrementing, * etc are not good solutions. Get your selector to be unique so idx isn’t used.

Why idx isn’t used in case of increment, Do you have any Reason?

We can use the idx for incrementing and click the value from the web page.

For example

In the below image i use the idx as increment value and it working good

image

Kindly suggest some example who can we use selector in the good way?

Regards
Gokul

Exactly! IDX with a * value should never be used at all.

1 Like

HI @mateo.drouillard

You can use aaname or innertext instead of idx

But sometimes we dont have or differnt data will be available in the innertext or aaname.

Regards
Sudharsan

1 Like

Because then you have to manage counting, incrementing, a way to know when you’re at the end, etc.

Just use For Each Ui Element. It’s what it’s designed for.

It won’t really hurt anything, it’s just the same as not having the idx in the selector at all. Basically it’s entirely pointless to have idx=‘*’ in a selector.

If you’re looping through elements on a page, use the For Each Ui Element activity

If IDX have default value of 1 or 2, the selector is ideal ?

You can’t say it is ideal but 1 or 2 is ok to have if you can’t do anything about it. No IDX is ideal.

@mateo.drouillard

No it is not always 1 or 2 , it completely based on the structure of the website

Regards
Sudharsan

1 Like