Best Practices Checklist

Writing Tests

  1. One test checks one behaviour; the name says it: wrongPasswordShowsError.
  2. Arrange (data) → Act (page methods) → Assert (one main assertion, soft asserts for related fields).
  3. No Thread.sleep; no implicit + explicit wait mix.
  4. No hard-coded URLs, users or passwords in tests; use config and secrets.
  5. Assertions have messages: assertEquals(actual, expected, "cart count after adding 2 items").

Running and Maintaining

  1. Quit the browser in @AfterMethod(alwaysRun = true).
  2. Screenshot, URL and page source on every failure.
  3. Quarantine a flaky test (a flaky group excluded from the gate) and open a ticket; do not delete it silently.
  4. Track the flaky rate per test; fix the worst ten every sprint.
  5. Keep the UI suite small: push checks down to API and unit tests where possible.
  6. Review test code like production code: same Git workflow, pull requests and code style.

Tip: In interviews, "how do you handle flaky tests?" is asked almost every time. Answer with: find the root cause (wait, locator, data), fix it, and use retries only for infrastructure, with reporting of retried tests.