Testing·Intermediate·Conceptual·1 min read
How should elements be selected in an e2e test?
Short interview answer
By accessible role and name where possible, or a dedicated data-testid attribute reserved for tests. Selecting by CSS class, tag structure, or text that also serves as copy makes tests break on unrelated visual or wording changes.
Key takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.