Selenium + Python · Lesson 35 of 43
Module 35: Test Data
Your task
Implement make_user(prefix):
Write it in the editor, then press Check answer (Ctrl + Enter).
import json
import time
def load_test_credentials(file_path: str):
with open(file_path, "r", encoding="utf-8") as f:
return json.load(f)
def generate_random_user():
return {
"username": f"user_{int(time.time())}@targetqa.com",
"role": "STANDARD"
}Hardcoding test data leads to brittle tests and limited coverage. In this lesson, you will master loading test datasets from JSON and CSV files and generating dynamic test users. Let's master test data!
Part of the Selenium + Python course (Selenium with Python). Practice this concept live in the Selenium Online Compiler or explore our free automation practice form.
Static emails trigger 'Email already registered' errors on subsequent test runs. Dynamic timestamps guarantee unique records.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___