Manuals / Linux & CLI for Testers / Chapter 7

B · Tester toolkit · intermediate · ~40 min · Chapter 7 of 9

Small scripts that help testing

Loops, variables, exit codes. Automate boring setup: seed data, wait for port, collect logs.

Path progress
78%

Step 1 of 1

Wait-for-url script

Wait-for-url scriptDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Wait-for-url scripdrag · tap →Try thisdrag · tap →Follow the dashed drag · tap →

Example

#!/usr/bin/env bash
set -euo pipefail
url=${1:-https://httpbin.org/status/200}
for i in {1..10}; do
  if curl -sf "$url" >/dev/null; then echo ready; exit 0; fi
  sleep 1
done
echo timeout >&2; exit 1

Do this now

Write a script that curls until 200 or times out.

Was this step clear?
Chapter learning outcomes
  • bash basics
  • exit codes
  • set -euo pipefail lite

Clear these before you leave