The 7 Golden Rules of Selenium Automation
1. Never use Thread.sleep: Always use explicit condition-based waits.
2. Never share WebDriver instances across parallel tests: Use ThreadLocal.
3. Encapsulate locators in Page Objects: Tests must never contain raw By locators.
4. Assert in Tests, not Page Objects: Page objects provide actions and state; test methods assert expectations.
5. Always clean up: Ensure driver.quit() runs in teardown hooks.
6. Prefer By.id and unique data-testid attributes: Avoid brittle multi-level absolute paths.
7. Ensure test independence: Every test must be able to run in isolation in any order.