Recall & Review
beginner
What is a utility class in Selenium Java?A utility class is a helper class that contains reusable methods to perform common tasks like waiting for elements, taking screenshots, or reading data. It helps avoid repeating code.Click to reveal answer
beginner
Why should utility classes have static methods?
Static methods allow calling utility functions without creating an object. This makes it easy to reuse methods anywhere in the test code.
Click to reveal answer
intermediate
Give an example of a common method in a Selenium utility class.
A method to wait for an element to be visible, like: <br>public static void waitForVisibility(WebDriver driver, WebElement element, int timeoutSeconds) {<br> new WebDriverWait(driver, Duration.ofSeconds(timeoutSeconds))<br> .until(ExpectedConditions.visibilityOf(element));<br>}
Click to reveal answer
intermediate
How do utility classes improve test maintenance?
By centralizing common code, utility classes make it easier to update logic in one place instead of many test files, reducing errors and saving time.
Click to reveal answer
beginner
What is a best practice when naming utility classes?
Use clear, descriptive names like 'WaitUtils' or 'ScreenshotHelper' to indicate the purpose of the class and improve code readability.Click to reveal answer
What is the main benefit of using utility classes in Selenium tests?
✗ Incorrect
Utility classes help reuse common code like waits or screenshots, reducing duplication and improving maintainability.
Which keyword is commonly used for methods in utility classes to avoid creating objects?
✗ Incorrect
Static methods can be called without creating an instance of the class, making them ideal for utility methods.
Which of the following is NOT a typical utility class method in Selenium?
✗ Incorrect
Launching the browser is usually handled by setup code, not utility classes focused on reusable helper methods.
What should you do if you need to change the way you wait for elements in all tests?
✗ Incorrect
Changing the wait method in the utility class updates all tests that use it, saving time and avoiding errors.
Which naming style is best for a utility class that handles waits?
✗ Incorrect
Clear and descriptive names like 'WaitUtils' help understand the class purpose quickly.
Explain what a utility class is and why it is useful in Selenium Java testing.
Think about helper methods you use often in tests.
You got /4 concepts.
Describe how static methods in utility classes help simplify test code.
Consider how you call methods from utility classes.
You got /3 concepts.