Playwright lab
Clock & timers
Countdowns, session timeouts, debounce and dates: control time with page.clock instead of waiting.
Practice tasks
- Call page.clock.install({ time }) before page.goto() and pin the visible date with page.clock.setFixedTime().
- Start the 60 s countdown and use page.clock.fastForward(60_000) to reach “Time’s up!”.
- Use page.clock.runFor() to tick the live clock exactly 5 seconds and assert the counter.
- Fast-forward 15 minutes and assert the session warning dialog, then 1 more minute for the logout.
- Type into the debounced search, fast-forward 500 ms and assert only ONE search ran.
- Pause at a date in 2027 and assert the coupon shows “expired”; move back to 2026 and see it valid.
- Assert the greeting for 08:00 (“Good morning”) and 20:00 (“Good evening”) using setFixedTime.