簡體   English   中英

WebDriver在find_elements_by_xpath上等待

[英]WebDriverWait on find_elements_by_xpath

我試圖弄清楚WebDriverWait如何與find_elements_by_xpath一起find_elements_by_xpath 它如何知道所有相關元素都已加載,還是只是等到頁面加載后才知道。

我可以理解我們是否使用find_element_by_xpath具有特定元素,但不確定使用find_elements_by_xpath

例如:

elements = WebDriverWait(driver, 5).until(lambda driver: driver.find_elements_by_xpath("//table[@id='%s']/tbody/tr" % myid))

一旦存在至少一個與XPath表達式匹配的元素,您所呈現的預期條件實際上將評估為True 換句話說,它等效於:

expression = "//table[@id='%s']/tbody/tr" % myid
wait.until(EC.presence_of_element_located((By.XPATH, expression)))

webdriver不在等待頁面加載-因為頁面的內容可能會不斷變化,所以它不會等待。 相反,它只執行find_elements_*命令,如果成功,則WebDriverWait(...).until調用將返回找到的元素。 它與find_element_by_xpath沒什么不同,除了可以返回一個以上的元素。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM