0
0
Selenium Pythontesting~5 mins

Element locators in page class in Selenium Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an element locator in Selenium?
An element locator is a way to find and select elements on a web page, like buttons or text fields, so you can interact with them in your tests.
Click to reveal answer
beginner
Why do we use a page class in Selenium tests?
A page class groups all element locators and actions for one web page in one place. It makes tests easier to read and maintain, like having a map for that page.
Click to reveal answer
beginner
Name four common locator strategies in Selenium.
Common locator strategies are: ID, Name, CSS Selector, and XPath. Each helps find elements differently, like using an address or a description.
Click to reveal answer
intermediate
What is the best practice for choosing locators in a page class?
Choose locators that are unique, stable, and simple. For example, prefer ID over XPath because IDs are usually unique and less likely to change.
Click to reveal answer
intermediate
How does using a page class improve test maintenance?
If a page changes, you only update locators in one place—the page class—instead of many test files. This saves time and reduces errors.
Click to reveal answer
Which locator is usually the most reliable to use in Selenium?
AClass Name
BXPath
CID
DTag Name
What is the main purpose of a page class in Selenium tests?
ATo group locators and actions for a web page
BTo run tests faster
CTo store test data
DTo generate reports
Which locator strategy uses a path-like syntax to find elements?
ACSS Selector
BXPath
CName
DID
If a locator changes on the web page, where should you update it?
AIn the test runner
BIn every test file
CIn the browser settings
DIn the page class
Which of these is NOT a good locator choice?
ARandomly generated class name
BStable CSS Selector
CName attribute
DUnique ID
Explain how element locators and page classes work together in Selenium tests.
Think about how you find things on a map and keep the map updated.
You got /4 concepts.
    Describe best practices for choosing element locators in a page class.
    Imagine picking the easiest and most reliable way to find a friend in a crowd.
    You got /4 concepts.