The Python Oracle

AttributeError: 'tuple' object has no attribute 'is_enabled'

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Track title: CC D Schuberts Piano Sonata D 850 in D

--

Chapters
00:00 Question
01:13 Accepted answer (Score 8)
02:15 Thank you

--

Full question
https://stackoverflow.com/questions/5799...

Accepted answer links:
[expected_conditions.staleness_of()]: https://seleniumhq.github.io/selenium/do...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #selenium

#avk47



ACCEPTED ANSWER

Score 9


You are passing in a tuple to a method that expects an element. From the expected_conditions.staleness_of() documentation:

class selenium.webdriver.support.expected_conditions.staleness_of(element)

Wait until an element is no longer attached to the DOM. element is the element to wait for.

This differs from some of the other expected_conditions convenience methods, which take a locator argument. This particular method can't take a locator, because a locator can only ever find elements that are still attached to the DOM.

Locate the element first before it has been detached:

from selenium.common.exceptions import NoSuchElementException

try:
    element = driver.find_element_by_xpath("//div[@class='loading_icon']")
    WebDriverWait(driver, 10).until(EC.staleness_of(element))
except NoSuchElementException:
    element = None