Bird
0
0

Which of the following is a correct way to implement a custom expected condition as a function in Selenium Python?

easy📝 Conceptual Q2 of 15
Selenium Python - Advanced Patterns
Which of the following is a correct way to implement a custom expected condition as a function in Selenium Python?
Adef condition(): return driver.title == 'Home Page'
Bdef condition(driver): driver.title == 'Home Page'
Cdef condition(driver): return driver.title == 'Home Page'
Ddef condition(driver): return driver.find_element('title')
Step-by-Step Solution
Solution:
  1. Step 1: Check function signature for expected condition

    It must accept 'driver' as parameter to access browser state.
  2. Step 2: Verify function returns a boolean or truthy value

    Returning the comparison result (True/False) is correct.
  3. Final Answer:

    def condition(driver): return driver.title == 'Home Page' -> Option C
  4. Quick Check:

    Custom condition function needs driver param and returns boolean [OK]
Quick Trick: Custom condition functions must accept driver and return True/False [OK]
Common Mistakes:
  • Omitting driver parameter
  • Not returning a value
  • Returning a WebElement instead of boolean

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes