When writing tests, you should always aim to use roles for grabbing elements in a DOM. By doing so, you make sure that your application is accessible for users. If you cannot use roles, then you should use aria properties. You should use test-ids as a last scenario. Never use classes as they may change and it will break your tests.