Challenge - 5 Problems
Page Class Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of a simple Page class method
Given the following Page class method, what will be the output when calling
get_title() if the page title is "Welcome Page"?Selenium Python
class HomePage: def __init__(self, driver): self.driver = driver def get_title(self): return self.driver.title # Assume driver.title returns "Welcome Page"
Attempts:
2 left
💡 Hint
Think about what the
driver.title property returns.✗ Incorrect
The
get_title method returns the title attribute of the driver, which is "Welcome Page".❓ assertion
intermediate2:00remaining
Correct assertion for verifying page URL
Which assertion correctly verifies that the current page URL contains the substring "dashboard" in a Page class test method?
Selenium Python
def test_dashboard_page(self): current_url = self.driver.current_url # Assertion goes here
Attempts:
2 left
💡 Hint
Check Python syntax for substring containment.
✗ Incorrect
Option A uses the correct Python syntax to check if "dashboard" is part of the current URL string.
❓ locator
advanced2:00remaining
Best locator strategy for a login button
Which locator is the best practice to find a login button with id="loginBtn" in a Page class?
Attempts:
2 left
💡 Hint
Using ID is usually the fastest and most reliable locator.
✗ Incorrect
Locating by ID is the most efficient and reliable method when the element has a unique ID.
🔧 Debug
advanced2:00remaining
Identify the error in this Page class method
What error will occur when running this method in a Page class?
Selenium Python
def click_submit(self): submit_button = self.driver.find_element(By.ID, "submitBtn") submit_button.click()
Attempts:
2 left
💡 Hint
Check the syntax of the find_element method call.
✗ Incorrect
The find_element method requires two arguments separated by a comma. Missing comma causes SyntaxError.
❓ framework
expert3:00remaining
Page class design for test maintainability
Which design choice best improves maintainability of Page classes in a Selenium Python test framework?
Attempts:
2 left
💡 Hint
Think about how to keep locators organized and reusable.
✗ Incorrect
Storing locators as class-level constants and encapsulating interactions in methods keeps code clean and easy to update.