0
0
Selenium Pythontesting~5 mins

Action methods in page class in Selenium Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AConfigure browser settings
BStore test data
CPerform a user interaction on the web page
DGenerate test reports
Where should locators be defined in a page class?
AAs class variables
BInside action methods
CIn the test script
DIn the test report
Which is a good name for an action method that types a password?
Apassword_input
Benter_password
Cclick_password
Dpassword_field
Why separate action methods from test logic?
ATo keep code clean and reusable
BTo make tests harder to read
CTo make tests slower
DTo avoid using locators
Which is NOT an example of an action method?
Aselect_country
Benter_username
Cclick_submit_button
Dcalculate_sum
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.