I have a page including iframe
tags, and want to catch if content is fully loaded in the iframe.
I use time.sleep with check document.readyState
and it works well in ideal cases ; strong and fast response from web server. But It seems not to guarantee all situations, and I want to improve my code.
Please tell me know some advice or tips. Thanks.
My envs
- os : windows 7 x64
- chrome : 68.0.3440.106 (official, 64bit)
- python : 3.6.6
- selenium : 3.14.0
I refer below documents.
- How to wait a page is loaded in Python Selenium
- Wait for page load in Selenium
- Selenium - How to wait until page is completely loaded
and i wrote code below
def wait_for_document(self, driver):
time.sleep(3)
for i in range(20):
if driver.execute_script("return document.readyState") == "complete" : return
else : time.sleep(1)