Python 2.7 Selenium,如何不等待页面加载

3
如何不必等待整个页面加载?有一个页面加载非常慢(至少需要3.5分钟才能完全加载网页),我不想等那么久。
在执行driver.get("slowwebpage.com")之后,是否可能让selenium不等待网页加载,而是等待某个元素例如:driver.find_element_by_id("element")可点击/可见时再操作?
1个回答

1

设置页面加载超时时间并捕获异常。

from selenium.common.exceptions import TimeoutException
try:
    driver.set_page_load_timeout(seconds)
except TimeoutException:
    pass

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接