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