from selenium.webdriver.support import expected_conditions as EC 解析
expected_conditions
是Selenium
的一個模selenium.webdriver.support.expected_conditions
,可以對網頁上元素是否存在,可點擊等等進行判斷,一般用於斷言或與WebDriverWait
配合使用。
例如:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
wait = WebDriverWait(self.driver,20)
wait.until(EC.presence_of_element_located((By.XPATH,'//div[@id="root"]')))#等到啥時候為止