Challenge - 5 Problems
Base Page Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this Selenium base page class method?
Consider this base page class method that waits for an element to be visible and returns its text.
What will be printed when calling
What will be printed when calling
get_element_text() if the element is visible and contains 'Hello World'?Selenium Python
from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC class BasePage: def __init__(self, driver): self.driver = driver def get_element_text(self, locator): element = WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located(locator) ) return element.text # Usage example: # base_page = BasePage(driver) # print(base_page.get_element_text((By.ID, 'greeting')))
Attempts:
2 left
💡 Hint
The method waits until the element is visible before getting text.
✗ Incorrect
The method waits up to 10 seconds for the element to be visible. If visible, it returns the element's text, which is 'Hello World'.
❓ locator
intermediate1:30remaining
Which locator is best practice for a base page class method?
You want to write a base page method that clicks a button reliably. Which locator is best to use?
Attempts:
2 left
💡 Hint
IDs are unique and fast to locate.
✗ Incorrect
Using By.ID is best practice because IDs are unique on the page and locating by ID is faster and more reliable.
❓ assertion
advanced1:30remaining
Which assertion correctly verifies a page title in a base page test?
You want to assert that the page title is exactly 'Dashboard'. Which assertion is correct?
Selenium Python
def test_page_title(base_page): title = base_page.driver.title # Which assertion below is correct?
Attempts:
2 left
💡 Hint
Exact match is needed for this test.
✗ Incorrect
The assertion must check that the title equals 'Dashboard' exactly, so option B is correct.
🔧 Debug
advanced2:00remaining
Why does this base page method raise TimeoutException?
This base page method waits for an element to be clickable but raises TimeoutException every time.
What is the likely cause?
What is the likely cause?
Selenium Python
def click_element(self, locator): element = WebDriverWait(self.driver, 5).until( EC.element_to_be_clickable(locator) ) element.click()
Attempts:
2 left
💡 Hint
TimeoutException means the condition was never met.
✗ Incorrect
TimeoutException usually means the locator did not find any clickable element within the wait time, often due to wrong locator.
❓ framework
expert2:30remaining
What is the main benefit of using a base page class in Selenium tests?
Choose the best explanation for why a base page class is used in Selenium test automation frameworks.
Attempts:
2 left
💡 Hint
Think about code reuse and organization.
✗ Incorrect
A base page class holds common methods and locators shared by multiple pages, reducing repeated code and making maintenance easier.