python 用selenuim判断页面是否全部加载完成,并且加上最大时长,超过时长报错

STR_READY_STATE = ''
time_start = time.time()
while STR_READY_STATE != 'complete':
     time.sleep(0.001)
     STR_READY_STATE = driver.execute_script('return document.readyState')
     time_end = time.time()
     if int(time_end - time_start) > 60:
        raise MyException("hpl 页面打开 超过60s")

 

 


 

异常类

class MyException(Exception):

    def __init__(self, *args):
        self.args = args

 

posted @ 2019-04-08 17:47  AngDH  阅读(3585)  评论(0编辑  收藏  举报