E2E Testing and Element IDs
I use Selenium to do E2E tests of a project built using Quasar but I’m running into dead ends when trying to assign IDs to various HTML elements so I can access these elements directly in my tests.
It’s obviously easy to assign custom IDs to components I’ve written myself, but anytime I use a Quasar component which in turns generates a bunch of HTML elements (often with child elements of their own) I have no way of assigning IDs to these elements and so I can’t access them directly in my tests.
Am I going about this the wrong way? Is there a better option for E2E testing? Or is the only option to look at the generated HTML code and dig down into child elements manually in the tests?
- Most elements generated by Quasar components have class names. Use that.
- Components encapsulate functionality. It’s generally a bad idea to base your tests on Quasar implementation details (such as inner HTML structure) because these details can change at any time without notice (while functionality remains the same). This goes for ANY framework out there.