I\'m using selenium in Python 2.7 and I have this code, but I\'m looking for a more efficient way to do this:
while True:
try:
element = WebDrive
1) Use staleness_of from expected condition
class staleness_of(object):
""" Wait until an element is no longer attached to the DOM.
element is the element to wait for.
returns False if the element is still attached to the DOM, true otherwise.
"""
2) WebDriverWait(driver, 10).until_not(...)
element = WebDriverWait(driver, 10).until(
EC.invisibility_of_element_located((By.ID, 'button'))
you don't need to use while. it already waits for time that you present in WebDriverWait() function.