我希望它等到搜索结果加载
WebDriverWait
(又称“显式等待”)。
您需要选择一个表示结果已加载的特定元素,然后等待。假设您正在等待可以通过
id
属于
mySearchResults
. 代码如下所示。
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# create driver and execute search here
# now wait for the presence of the `mySearchResults` element.
# if it is not found within 10 secs, a `TimeOutException` is raised.
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "mySearchResults")))