Bird
Raised Fist0
Selenium Pythontesting~20 mins

Fluent waits in Selenium Python - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Fluent Wait Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Output of Fluent Wait with Polling Interval
What will be the output of this Selenium Python code snippet using Fluent Wait?
Selenium Python
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException

class DummyDriver:
    def __init__(self):
        self.attempts = 0
    def find_element(self, by, value):
        self.attempts += 1
        if self.attempts < 3:
            raise Exception('Element not found')
        return 'Element Found'

driver = DummyDriver()

wait = WebDriverWait(driver, 5, poll_frequency=1, ignored_exceptions=[Exception])
try:
    element = wait.until(lambda d: d.find_element(By.ID, 'myId'))
    print(element)
except TimeoutException:
    print('Timeout')
AElement Found
BTimeout
CException: Element not found
DSyntaxError
Attempts:
2 left
💡 Hint
The wait retries every 1 second and ignores exceptions until the element is found or timeout.
❓ assertion
intermediate
1:30remaining
Correct Assertion for Fluent Wait Result
Which assertion correctly verifies that a Fluent Wait found the element with text 'Submit'?
Selenium Python
element_text = 'Submit'  # Assume this is the text of the found element
Aassert element_text != 'Submit'
Bassert element_text == 'Submit'
Cassert element_text is None
Dassert element_text > 'Submit'
Attempts:
2 left
💡 Hint
The assertion should confirm the element text matches exactly.
🔧 Debug
advanced
2:00remaining
Identify the Error in Fluent Wait Usage
What error will this Selenium Python code raise when using Fluent Wait incorrectly?
Selenium Python
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

wait = WebDriverWait(driver, 10, poll_frequency=0.5)
element = wait.until(EC.presence_of_element_located('myId'))
ATimeoutException
BSyntaxError
CNoSuchElementException
DTypeError: argument of type 'str' is not iterable
Attempts:
2 left
💡 Hint
Check the argument passed to presence_of_element_located.
🧠 Conceptual
advanced
1:30remaining
Why Use Fluent Wait Instead of Implicit Wait?
Which reason best explains why Fluent Wait is preferred over Implicit Wait in Selenium?
AFluent Wait automatically retries without any timeout.
BImplicit Wait is faster and more reliable than Fluent Wait.
CFluent Wait allows setting polling frequency and ignoring specific exceptions, giving more control.
DImplicit Wait can only be used with Java, not Python.
Attempts:
2 left
💡 Hint
Think about flexibility and control over waiting behavior.
❓ locator
expert
2:00remaining
Best Locator Strategy for Fluent Wait
Which locator tuple is best to use with Fluent Wait's presence_of_element_located to find a button with id 'submitBtn'?
A(By.ID, 'submitBtn')
B('id', 'submitBtn')
C(By.CSS_SELECTOR, '#submitBtn')
D(By.XPATH, '//button[@id="submitBtn"]')
Attempts:
2 left
💡 Hint
Use the standard Selenium locator tuple format.

Practice

(1/5)
1. What is the main purpose of using a FluentWait in Selenium Python?
easy
A. To pause the test execution for a fixed time
B. To repeatedly check for a condition until it is met or a timeout occurs
C. To immediately find an element without waiting
D. To run tests in parallel threads

Solution

  1. Step 1: Understand FluentWait behavior

    FluentWait repeatedly checks for a condition, like element presence, until timeout or success.
  2. Step 2: Compare options

    Only To repeatedly check for a condition until it is met or a timeout occurs describes this repeated checking with timeout. Others describe different concepts.
  3. Final Answer:

    To repeatedly check for a condition until it is met or a timeout occurs -> Option B
  4. Quick Check:

    FluentWait = repeated checks with timeout [OK]
Hint: FluentWait keeps trying until success or timeout [OK]
Common Mistakes:
  • Confusing FluentWait with fixed sleep
  • Thinking FluentWait runs tests in parallel
  • Assuming FluentWait finds elements instantly
2. Which of the following is the correct way to create a FluentWait object in Selenium Python?
easy
A. wait = FluentWait(driver).with_timeout(10).polling_every(1).ignoring(NoSuchElementException)
B. wait = FluentWait(driver, timeout=10, poll_interval=1, ignored_exceptions=[NoSuchElementException])
C. wait = WebDriverWait(driver, 10).pollingEvery(1).ignoring(NoSuchElementException)
D. wait = FluentWait(driver).timeout(10).poll(1).ignore(NoSuchElementException)

Solution

  1. Step 1: Recall FluentWait syntax in Selenium Python

    The correct syntax chains methods: with_timeout(), polling_every(), ignoring() on FluentWait instance.
  2. Step 2: Analyze options

    wait = FluentWait(driver).with_timeout(10).polling_every(1).ignoring(NoSuchElementException) matches correct chaining syntax. wait = FluentWait(driver, timeout=10, poll_interval=1, ignored_exceptions=[NoSuchElementException]) uses wrong constructor parameters. wait = WebDriverWait(driver, 10).pollingEvery(1).ignoring(NoSuchElementException) uses WebDriverWait, not FluentWait. wait = FluentWait(driver).timeout(10).poll(1).ignore(NoSuchElementException) uses incorrect method names.
  3. Final Answer:

    wait = FluentWait(driver).with_timeout(10).polling_every(1).ignoring(NoSuchElementException) -> Option A
  4. Quick Check:

    FluentWait chaining methods = wait = FluentWait(driver).with_timeout(10).polling_every(1).ignoring(NoSuchElementException) [OK]
Hint: FluentWait uses chained methods like with_timeout() [OK]
Common Mistakes:
  • Using WebDriverWait instead of FluentWait
  • Passing parameters directly to constructor
  • Using wrong method names like timeout()
3. What will be the output of the following code snippet if the element with id 'submit' appears after 3 seconds?
from selenium.webdriver.support.ui import FluentWait
from selenium.common.exceptions import NoSuchElementException

wait = FluentWait(driver).with_timeout(5).polling_every(1).ignoring(NoSuchElementException)
element = wait.until(lambda d: d.find_element('id', 'submit'))
print(element.tag_name)
medium
A. Raises NoSuchElementException after 5 seconds
B. Raises TimeoutException immediately
C. Prints the tag name of the 'submit' element after about 3 seconds
D. Prints None immediately

Solution

  1. Step 1: Understand FluentWait timing

    FluentWait waits up to 5 seconds, checking every 1 second, ignoring NoSuchElementException.
  2. Step 2: Analyze element appearance

    The element appears after 3 seconds, which is within the 5-second timeout, so wait.until returns the element.
  3. Step 3: Print element tag name

    After wait.until returns, print outputs the tag name of the found element.
  4. Final Answer:

    Prints the tag name of the 'submit' element after about 3 seconds -> Option C
  5. Quick Check:

    Element found within timeout = prints tag name [OK]
Hint: FluentWait waits until element appears or timeout [OK]
Common Mistakes:
  • Expecting immediate TimeoutException
  • Thinking NoSuchElementException is raised
  • Assuming print outputs None
4. Identify the error in this FluentWait usage:
wait = FluentWait(driver).with_timeout(10).polling_every(2)
element = wait.until(lambda d: d.find_element_by_id('login'))
medium
A. Using deprecated method find_element_by_id instead of find_element
B. Missing ignoring() to handle exceptions
C. Polling interval is too long
D. Timeout value should be in milliseconds

Solution

  1. Step 1: Check method usage for element finding

    In Selenium Python 3.12+, find_element_by_id is deprecated; use find_element('id', 'login').
  2. Step 2: Review other options

    Ignoring exceptions is optional but recommended; polling_every uses seconds; timeout is in seconds, so no error there.
  3. Final Answer:

    Using deprecated method find_element_by_id instead of find_element -> Option A
  4. Quick Check:

    Deprecated method usage = Using deprecated method find_element_by_id instead of find_element [OK]
Hint: Use find_element with locator tuple, not deprecated methods [OK]
Common Mistakes:
  • Ignoring deprecation warnings
  • Confusing polling interval units
  • Assuming timeout needs milliseconds
5. You want to wait for a button with CSS selector '.submit-btn' to be clickable, checking every 500 milliseconds, with a timeout of 8 seconds, ignoring ElementNotInteractableException. Which FluentWait code snippet correctly implements this?
hard
A. wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException) element = wait.until(lambda d: d.find_element('css selector', '.submit-btn').is_enabled())
B. wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException) element = wait.until(lambda d: d.find_element_by_css_selector('.submit-btn').is_enabled())
C. wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException) element = wait.until(lambda d: d.find_element('css selector', '.submit-btn').clickable())
D. wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException) element = wait.until(lambda d: d.find_element('css selector', '.submit-btn') if d.find_element('css selector', '.submit-btn').is_enabled() else False)

Solution

  1. Step 1: Set FluentWait with correct timeout, polling, and ignoring

    All options set timeout 8s, polling 0.5s, ignoring ElementNotInteractableException correctly.
  2. Step 2: Check lambda condition for clickable

    wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException) element = wait.until(lambda d: d.find_element('css selector', '.submit-btn') if d.find_element('css selector', '.submit-btn').is_enabled() else False) returns the element only if is_enabled() is True; else returns False to keep waiting. This is correct usage.
  3. Step 3: Identify errors in other options

    wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException) element = wait.until(lambda d: d.find_element('css selector', '.submit-btn').is_enabled()) returns boolean from is_enabled(), not element; wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException) element = wait.until(lambda d: d.find_element('css selector', '.submit-btn').clickable()) uses non-existent clickable() method; wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException) element = wait.until(lambda d: d.find_element_by_css_selector('.submit-btn').is_enabled()) uses deprecated find_element_by_css_selector.
  4. Final Answer:

    wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException)\nelement = wait.until(lambda d: d.find_element('css selector', '.submit-btn') if d.find_element('css selector', '.submit-btn').is_enabled() else False) -> Option D
  5. Quick Check:

    Return element only when clickable = wait = FluentWait(driver).with_timeout(8).polling_every(0.5).ignoring(ElementNotInteractableException)\nelement = wait.until(lambda d: d.find_element('css selector', '.submit-btn') if d.find_element('css selector', '.submit-btn').is_enabled() else False) [OK]
Hint: Return element only when condition true inside wait.until lambda [OK]
Common Mistakes:
  • Returning boolean instead of element in wait.until
  • Using deprecated find_element_by_css_selector
  • Calling non-existent clickable() method
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard