I have recently answered a similar question here: https://forum.mendix.com/link/space/testing/questions/122737
In addition to the answer given in the other question, I can recommend that you use mx-name-{ElementName} or classnames to pin to individual items on your page. However, do not pin your xPaths on dynamic mx-name- classes, because these use the order on which they are placed on the Page document in your Mendix application. Instead, make sure your developers specify names for the elements to-be-tested in the properties of elements such as DataGrids, DataViews, etc.