Selector
// Definition
A CSS or XPath expression that identifies one or more DOM elements. Often used interchangeably with 'locator', though locator is the broader concept.
// Code Example
// 1. data-test attribute — best, survives DOM refactors
cy.get('[data-testid="submit-button"]').click();
// 2. CSS selector — ok for stable styling targets
cy.get('button.primary').click();
// 3. XPath — last resort, brittle
cy.xpath('//button[contains(text(), "Submit")]').click();// Related terms
Locator
A description of how to find an element on a page — by id, CSS, XPath, role, or test attribute. Modern frameworks prefer role and test-id locators because they're resilient to DOM changes.
Auto-waiting
A framework feature that pauses an action until the target element is actionable (visible, enabled, stable). Eliminates most need for explicit sleeps and reduces flake.
Page Object Model (POM)
A design pattern that wraps page interactions in dedicated classes. Tests call methods like `loginPage.signIn(email, password)` instead of manipulating selectors directly. Improves maintainability when locators change.
Learn more · JavaScript for QA
Chapter 6 · Lesson 2: Selecting Elements — querySelector and getElementById