Playwright + Java · Lesson 7 of 38
Module 7: Collections
Your task
Implement filterAdminUsers:
Write it in the editor, then press Check answer (Ctrl + Enter).
import java.util.*;
// List of harvested UI texts:
List<String> productTitles = new ArrayList<>();
productTitles.add("Wireless Mouse");
productTitles.add("Mechanical Keyboard");
// Map for API headers:
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "Bearer eyJhbGci...");
headers.put("Content-Type", "application/json");
// Iterate with for-each:
for (Map.Entry<String, String> entry : headers.entrySet()) {
System.out.println(entry.getKey() + " -> " + entry.getValue());
}Unlike fixed-length arrays, Java Collections dynamically grow as you harvest web elements, query databases, or parse API responses. In this lesson, we master List, ArrayList, Set, HashSet, and Map to handle dynamic test data. Let's dive in!
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.
List maintains insertion order and allows duplicates (e.g. items in a dropdown). Set guarantees uniqueness and disallows duplicates.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___