Bird
0
0

Given this custom expected condition class, what will WebDriverWait(driver, 10).until(MyCondition()) return if the page title is 'Dashboard'?

medium📝 Predict Output Q13 of 15
Selenium Python - Advanced Patterns
Given this custom expected condition class, what will WebDriverWait(driver, 10).until(MyCondition()) return if the page title is 'Dashboard'?
class MyCondition:
    def __call__(self, driver):
        if driver.title == 'Dashboard':
            return True
        else:
            return False
AIt will raise a TimeoutException immediately
BIt will return the driver object
CIt will return False immediately without waiting
DIt will wait until the title is 'Dashboard' and then return True
Step-by-Step Solution
Solution:
  1. Step 1: Understand WebDriverWait with custom condition

    WebDriverWait calls the condition repeatedly until it returns a truthy value or timeout.
  2. Step 2: Analyze the condition's return value

    If the title is 'Dashboard', __call__ returns True, so wait ends and returns True.
  3. Final Answer:

    It will wait until the title is 'Dashboard' and then return True -> Option D
  4. Quick Check:

    Condition returns True -> wait ends successfully [OK]
Quick Trick: Wait ends when condition returns True [OK]
Common Mistakes:
  • Thinking it raises TimeoutException immediately
  • Assuming it returns False immediately
  • Confusing return value with driver object

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes