Automation lab Aú API Interaction & Mocking (API_INTERACTION)
Lab 034: Mock delayed API and verify loading state
Practice mock delayed api and verify loading state in a real web app context as part of the API Interaction & Mocking module.
intermediate
intermediate
Objectives
Use for test scripts- Understand the purpose and business flow of mock delayed api and verify loading state.
- Design stable locators for key UI elements.
- Automate user interactions and verify the resulting UI state.
Sandbox
API & Network • api • intermediate • active
Mock delayed API and verify loading state
Show loading while waiting for a delayed API response.
Reading and understanding requirements
Choosing stable locators
Designing assertions based on business rules
Learning objectives
- Display loading indicator during async wait.
- Swap loading state for success data.
- Assert timing/visibility of spinner and content.
Steps
- Trigger delayed fetch.
- Verify spinner visible immediately.
- After delay, spinner hides and data shows.
Practice sandbox
Simulate a 1s delay.
Idle
Data fetched
- Order #1234
- Status: Processing
- Amount: $250
Assertions to practice
- Spinner appears immediately on fetch.
- Spinner hides and data appears after delay.
- Status text tracks Idle → Loading → Success.