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
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

  1. Trigger delayed fetch.
  2. Verify spinner visible immediately.
  3. After delay, spinner hides and data shows.

Practice sandbox

Simulate a 1s delay.

Idle

Assertions to practice

  • Spinner appears immediately on fetch.
  • Spinner hides and data appears after delay.
  • Status text tracks Idle → Loading → Success.