Recall & Review
beginner
What is an action method in a page class?
An action method is a function inside a page class that performs a user action on the web page, like clicking a button or entering text.Click to reveal answer
beginner
Why do we use action methods in page classes?
We use action methods to keep test code clean and reusable by separating page interactions from test logic.
Click to reveal answer
beginner
Example of an action method to click a login button in Python Selenium:
def click_login(self):
self.driver.find_element(*self.login_button).click()
Click to reveal answer
intermediate
How should locators be used inside action methods?
Locators should be defined as class variables and used inside action methods to find elements. This keeps locators organized and easy to update.Click to reveal answer
beginner
What is a good practice when naming action methods?
Name action methods clearly to describe the user action, like 'enter_username' or 'submit_form', so tests are easy to read.
Click to reveal answer
What does an action method in a page class usually do?
✗ Incorrect
Action methods perform user interactions like clicks or typing on the web page.
Where should locators be defined in a page class?
✗ Incorrect
Locators should be class variables to keep them organized and reusable.
Which is a good name for an action method that types a password?
✗ Incorrect
Action methods should be named with verbs describing the action, like 'enter_password'.
Why separate action methods from test logic?
✗ Incorrect
Separating action methods keeps code clean and makes it easier to reuse.
Which is NOT an example of an action method?
✗ Incorrect
'calculate_sum' is not a user action on the page, so it is not an action method.
Explain what an action method is and why it is useful in a page class.
Think about how you interact with a website and how that can be coded.
You got /4 concepts.
Describe best practices for naming and organizing action methods and locators in a page class.
Consider how to make your code easy to read and maintain.
You got /4 concepts.