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
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
- Attempt access while logged out → blocked.
- Log in, retry → content visible.
- Log out again → access revoked.
Practice sandbox
Toggle auth and access a protected route.
Access denied: please log in
Protected content: welcome!
Status: Logged out
Assertions to practice
- Guard blocks anonymous users.
- Redirect message appears when blocked.
- Protected content only when logged in.