python selenuim如何判断下拉框是否加载出来,超过时间不再等待
s_flag = True time_start = time.time() while s_flag: doc = etree.HTML(unicode.encode(driver.page_source, encoding='utf-8')) from_list = doc.xpath("""//*[@id="ext-gen267"]/div""") if len(from_list) == 0: time_end = time.time() if int(time_end - time_start) > 15: # 超过 n 秒 没有 下拉框 ,不再等待 s_flag = False else: # 有下拉框 ,退出 循环 break