我正在尝试等待驱动程序等待,直到找到同一类的所有元素。
例如:
如果是 foo
我尝试:
WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.CLASS_NAME, 'foo')))
我认为这只等待该类中第一个出现的元素。任何人都知道如何才能等到该类的所有元素都找到。
WebDriverWait与Expected_conditions结合使用,因为presence_of_element_located()
它将等待第一个匹配的WebElement。
等到同一类如的所有元素富 阶级的存在,而不是presence_of_element_located()
你需要引起WebDriverWait的presence_of_all_elements_located()和你的有效代码块将是:
WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.CLASS_NAME, 'foo')))
注意:您必须添加以下导入:
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句