Recall & Review
beginner
What are action methods in the context of a Page Object Model?
Action methods are functions inside a page class that perform user interactions like clicking buttons, entering text, or selecting options on that page.Click to reveal answer
beginner
Why should each page class have its own action methods?To keep tests organized and easy to maintain by grouping all actions related to a page in one place, making the code reusable and clear.
Click to reveal answer
beginner
Give an example of a simple action method in a login page class.
public void enterUsername(String username) {
usernameField.sendKeys(username);
}
This method types the username into the username field.
Click to reveal answer
intermediate
How do action methods improve test readability?
They let test scripts read like instructions, for example: loginPage.enterUsername("user"); loginPage.clickLogin(); which is easy to understand.Click to reveal answer
beginner
What is a best practice when naming action methods?
Use clear, simple names that describe the action, like clickSubmitButton() or selectCountry(String country), so anyone can understand what the method does.
Click to reveal answer
What is the main purpose of action methods in a page class?
✗ Incorrect
Action methods are designed to perform user interactions like clicking or typing on the page.
Where should action methods be defined in Selenium tests using Page Object Model?
✗ Incorrect
Action methods belong in the page class to keep page-related actions organized.
Which of the following is a good name for an action method that clicks a login button?
✗ Incorrect
clickLoginButton() clearly describes the action and the element involved.
Why is it better to have separate action methods for each user interaction?
✗ Incorrect
Separate action methods help reuse code and make tests easier to read and maintain.
What should an action method NOT do?
✗ Incorrect
Assertions should be in test methods, not in action methods which only perform actions.
Explain what action methods are and why they are important in the Page Object Model.
Think about how you would tell a friend what these methods do on a webpage.
You got /3 concepts.
Describe best practices for writing action methods in Selenium Java tests.
Focus on naming, organization, and responsibilities.
You got /4 concepts.