lecture 8 of 180 completed

Logging in once for the whole suite

storageState saves your login to a file so tests start logged in, without depending on each other.

What you'll learn

  • How storageState removes repeated logins
  • Why the file must not be committed
  • How to handle several roles

This one needs a real project: it saves your session to a file on disk, which the editor here has no way to do. It is worth reading anyway, because almost every Playwright suite in a real company uses it.

Logging in through the form takes about three seconds. That sounds small. With eighty tests it is four minutes of every run, spent typing the same password.

You might think: log in once, then let the other tests use that session. Please do not. Your tests would depend on each other, and a single test would fail when run alone.

full course

Keep reading with the full course

The Foundations track and the first lessons in each framework are free. This lesson needs full course access. A course plan includes all lessons for Playwright, Cypress and Selenium.

See course plans →