There are 2-3 more grids such as “A” and “B” grids, they are opened according to their order of operation. Grid “A” is the main grid. However, the idx numbers of all of them change each time the grid is opened.
Sample;
Before b is opened, grid a is idx=2, but since grid b is opened, grid a becomes 3 and b becomes 2. When grid c is opened, grid a becomes 2 again, grid c 1, grid 3 b.
I click on grid A, but when grid c b is opened, click goes to grid b.
I have to go back to the beginning every time there is a loop.
In many scenarios idx is dynamic, therefore may cause your selectors to be unreliable. While I don’t know how your application behaves I can suggest to change the approach using for example anchor base or find relative element.