Playwright + Java · Lesson 29 of 38
Module 29: Test Data
Your task
Create a method generateRandomUsername():
Write it in the editor, then press Check answer (Ctrl + Enter).
public class UserCredentials {
private String email;
private String password;
private String expectedRole;
// Getters and Setters
public String getEmail() { return email; }
public String getPassword() { return password; }
public String getExpectedRole() { return expectedRole; }
}
// Data provider streaming multiple scenarios:
List<UserCredentials> testUsers = Arrays.asList(
new UserCredentials("admin@targetqa.com", "adminPass", "ADMIN"),
new UserCredentials("user@targetqa.com", "userPass", "STANDARD")
);Hardcoded test data limits coverage. In this lesson, you will master Data-Driven Testing. You will learn to parse JSON and CSV data into strongly typed Java POJOs and drive automated tests with multiple user scenarios and roles. Let's master test data!
Part of the Playwright + Java course (Playwright with Java). Practice this concept live in the Playwright Online Compiler or explore our free automation practice form.
Static usernames fail on subsequent test runs due to uniqueness constraints (e.g. 'Email already registered'). Dynamic timestamps prevent collisions.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___