1

I have the following sample code:

try:
  element_found = WebDriverWait(driver, 10).until(EC.presence_of_element_located(By.XPATH,'//div[@class='sample-class']))
  print("Success")
except Exception:
  print("Failure")

When the element is located then the wait time of 10 seconds is honored and so the time taken to print 'Success' is <=10 seconds but when the expected condition fails then the time taken to print 'Failure' is 50 seconds consistently.

So why is the 10 seconds limit not honored for a failure case? Why is it taking 50 seconds?

cruisepandey
  • 28,520
  • 6
  • 20
  • 38
codesol99
  • 11
  • 1

1 Answers1

1

Looks like you have

driver.implicitly_wait(30)

Implicit wait as well in your code.

This is what officials has got to say about mixing of Implicit wait with explicit wait :

Warning: Do not mix implicit and explicit waits. Doing so can cause unpredictable wait times. For example, setting an implicit wait of 10 seconds and an explicit wait of 15 seconds could cause a timeout to occur after 20 seconds.

Reference link

cruisepandey
  • 28,520
  • 6
  • 20
  • 38