Automation lab Aú State & Session Management (STATE_SESSION)

Lab 043: Protected routes and auth guard

Practice protected routes and auth guard in a real web app context as part of the State & Session Management module.

intermediate intermediate
intermediate

Objectives

Use for test scripts
  • Understand the purpose and business flow of protected routes and auth guard.
  • Design stable locators for key UI elements.
  • Automate user interactions and verify the resulting UI state.

Sandbox

Auth & Session • auth • intermediate • active

Protected routes and auth guard

Simulate route access based on authentication; guard blocks guests.

Reading and understanding requirements Choosing stable locators Designing assertions based on business rules

Learning objectives

  • Assert guard behavior for anonymous vs authenticated.
  • Validate redirect message and status.
  • Verify protected content visible only when logged in.

Steps

  1. Attempt access while logged out → blocked.
  2. Log in, retry → content visible.
  3. Log out again → access revoked.

Practice sandbox

Toggle auth and access a protected route.

Status: Logged out

Assertions to practice

  • Guard blocks anonymous users.
  • Redirect message appears when blocked.
  • Protected content only when logged in.