Skip to the page

UI automation · mid

Playwright login fixtures, Cypress and choosing a tool

Log in once and reuse the saved state. Know how Cypress differs, and choose a tool by team and need, not by hype.

The notes

What you must know

  • A setup project logs in once and saves storageState to a file. Test projects use dependencies: ["setup"] and the storageState path.
  • For parallel runs use one account per worker: a worker-scoped fixture picks an account by test.info().parallelIndex. Logging in through the API is faster.
  • Fixtures run only when a test asks for them. Code after await use(...) is the teardown. Worker fixtures run once per worker, test fixtures once per test.
  • Put the auth folder in .gitignore. It holds live session cookies. Refresh the state when it expires.
  • Cypress runs the test code inside the browser next to the app. Selenium and Playwright drive the browser from outside.
  • Cypress commands are queued, not promises. await cy.get() does not work; use then(), aliases or cy.wrap.
  • Cypress limits: JavaScript or TypeScript only, one browser at a time, no direct support for multiple tabs, cy.origin() for another origin, partial iframe support. WebKit support is experimental.
  • Choose by team skills, languages, browsers and devices needed, speed and flakiness, debugging tools, parallel cost, and existing code. Playwright covers Chromium, Firefox and WebKit. Selenium covers real branded browsers and every major language.
  • Do not rewrite 800 tests in one go. Move a few at a time.

The red pen

Common traps: mistake → fix

  • Mistake: One shared account for all workers is fine

    Fix: one test cart or logout breaks another.

  • Mistake: Cypress is Selenium with a nicer UI

    Fix: it runs inside the browser and has different limits.

  • Mistake: Selenium is dead

    Fix: it is the W3C standard and many teams use it.

Easy to hard

Questions interviewers ask, easy to hard

  1. How do you log in once in Playwright and reuse it in every test?
  2. How is Cypress different from Selenium?
  3. How would you choose a tool for a new project?
  4. Why must the saved auth file stay out of git?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview