Sobes.tech
Junior — Middle

What types of expectations can you list in the context of software development?

sobes.tech AI

Answer from AI

In the context of software development, several types of expectations are distinguished, especially in testing and automation:

  • Hard waits — fixed waiting time, for example, sleep(5). Rarely used as they are inefficient and slow down tests.
  • Explicit waits — waiting for a specific condition or event with a timeout. For example, waiting for an element to appear on the page.
  • Implicit waits — setting a waiting time for element search, during which the driver will retry attempts for the specified duration.
  • Event-based waits — waiting based on the occurrence of a specific event, such as the completion of a file download.

Example of explicit wait in Python with Selenium:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
element = wait.until(EC.presence_of_element_located((By.ID, 'myElement')))