期望条件期望传递元组,其中第一项是定位器的类型(By
常量),第二项是定位器的值:
from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC wait = WebDriverWait(browser, 10) wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="hplogo"]')))
请注意,在您的情况下By.ID
会更简单:
wait.until(EC.presence_of_element_located((By.ID, 'hplogo')))