I've used selenium a lot but have not had occasion to use WebDriverWait. Now I am in need to click a Back button which, although it seems to be immediately available, it must occasionally not be for a split second. I can put it in a loop with a time.sleep(1) and it will occasionally loop once. I can live with this but I thought this to be the perfect opportunity to implement a WebDriverWait. This works:
browser.find_element_by_xpath('//div[@onclick="backToResults();"]')
except for the occasional NoSuchElementException...
This won't work, it just runs the 3 seconds and times out (regardless of the amount of time I try, it never returns successful):
elem = WebDriverWait(browser, 3).until(ec.presence_of_element_located((By.XPATH, '//div[@onclick="backToResults();')))
...but the same ec call without the wait does returns the element, so the wait should be working:
ec.presence_of_element_located((By.XPATH, '//div[@onclick="backToResults();'))
So, it's not that the element is not there and is accessible, at least within a second or so, but the WebDriverWait isn't returning from the positive EC call?