In a rather complex python-selenium test script (which is not accessible from the outside, so I cannot provide an example), I have the following line waiting for an element to become visible:
WebDriverWait(basedriver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.ID,"clb-iframe-workspace")))
elem = WebDriverWait(basedriver, 20).\
until(EC.element_to_be_clickable((By.XPATH, '//div[contains(text(), "Feature extraction")]')))
In most cases there is no problem and the web driver finds the element in question. But sometimes (about 1 in 10 cases) I get the following error:
WebDriverException: Message: TypeError: can't access dead object
And strangely that happens right away! Selenium does not even bother to wait the 20 seconds I want selenium to wait by using WebDriverWait
!
Maybe the iframe
switch could have something to do with it?
I also tried to make a screenshot just before the failing line - I get a blank white screen in both cases. So how to debug this any further myself? And why does the WebDriverWait
not wait...?
Addendum
- I have implemented the suggestion from DebanjanB, but I still get the same error at a level of 5%.
- If I use a slower internet connection, the error takes place almost all the time!
- When I insert code to take screenshots and write out the page source (which takes some time to do), the error rate decreases again.
So I would say its definitive a timing issue, combined with a bug in selenium...