I have a test which has method to upload file in form located in iframe
.
The problem is that test not stable and sometimes fails with the error (run three times to get error example, third run failed):
def fill_offer_image(self):
driver = self.app.driver
driver.switch_to.frame(driver.find_elements_by_name("upload_iframe")[3])
E IndexError: list index out of range
I have implicitly wait = 10
and as you can consider few iframes on the page with the same class so I've been forced to use arrays. And sometimes not all (or all?) iframes loaded.
Does someone have thoughts how to improve stability of that test? Could it relate to mechanics of iframe itself?
Lets try this by giving some time for iframe to load by inserting the below code
hope this will work
I would use an Explicit Wait and wait until the count of frame elements with
name="upload_iframe"
becomes 4 by writing a custom expected condition:Usage: