Conditions and loops
Conditions
if (age >= 18) {
System.out.println("Adult");
} else {
System.out.println("Minor");
}
Loops
for (int i = 0; i < 5; i++) { ... }
while (condition) { ... }
do { ... } while (condition);
Why Testers Use These Constantly
Loops are used to iterate over a list of WebElements (like all rows in a table), and conditions are used to branch logic based on page state (e.g., only click a button if it's visible).
PreviousJava programming concepts: Class, Object, variables, methods, Packages
Next Access and non-access modifiers
Ready to master real-world software testing?
Learn manual and automation testing hands-on with mentor-led sessions.
.png)