The Python Oracle

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

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay

--

Chapters
00:00 Attributeerror: 'Tuple' Object Has No Attribute 'Is_enabled'
00:58 Accepted Answer Score 9
01:45 Thank you

--

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

--

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